From patchwork Tue Dec 7 02:07:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 74486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 514FFB70B0 for ; Tue, 7 Dec 2010 13:07:17 +1100 (EST) Received: (qmail 23861 invoked by alias); 7 Dec 2010 02:07:14 -0000 Received: (qmail 23852 invoked by uid 22791); 7 Dec 2010 02:07:13 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Dec 2010 02:07:09 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id oB7276Qw013559 for ; Mon, 6 Dec 2010 18:07:06 -0800 Received: from elbrus2.mtv.corp.google.com (elbrus2.mtv.corp.google.com [172.18.116.96]) by wpaz9.hot.corp.google.com with ESMTP id oB72758K006556; Mon, 6 Dec 2010 18:07:05 -0800 Received: by elbrus2.mtv.corp.google.com (Postfix, from userid 74925) id D0879190950; Mon, 6 Dec 2010 18:07:04 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: ppluzhnikov@google.com Subject: [patch] Fix for PR 46830 Message-Id: <20101207020704.D0879190950@elbrus2.mtv.corp.google.com> Date: Mon, 6 Dec 2010 18:07:04 -0800 (PST) From: ppluzhnikov@google.com (Paul Pluzhnikov) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Greetings, Here is a proposed patch for PR 46830: overlapped memcpy() on s.swap(s) in versa_string. [Google has blanket copyright assignment to FSF, and the patch is trivial.] Thanks, --- Paul Pluzhnikov libstdc++-v3/ChangeLog: 2010-12-06 Paul Pluzhnikov PR 46830 * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Avoid unnecessary work on swap with self. Index: libstdc++-v3/include/ext/sso_string_base.h =================================================================== --- libstdc++-v3/include/ext/sso_string_base.h (revision 167521) +++ libstdc++-v3/include/ext/sso_string_base.h (working copy) @@ -232,6 +232,9 @@ __sso_string_base<_CharT, _Traits, _Alloc>:: _M_swap(__sso_string_base& __rcs) { + if (this == &__rcs) + return; + // _GLIBCXX_RESOLVE_LIB_DEFECTS // 431. Swapping containers with unequal allocators. std::__alloc_swap<_CharT_alloc_type>::_S_do_it(_M_get_allocator(),