Patchwork Fix for PR 46830

login
register
mail settings
Submitter Paul Pluzhnikov
Date Dec. 7, 2010, 2:07 a.m.
Message ID <20101207020704.D0879190950@elbrus2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/74486/
State New
Headers show

Comments

Paul Pluzhnikov - Dec. 7, 2010, 2:07 a.m.
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  <ppluzhnikov@google.com>

	PR 46830
	* include/ext/sso_string_base.h (__sso_string_base<>::_M_swap):
	Avoid unnecessary work on swap with self.
Paolo Carlini - Dec. 7, 2010, 2:44 a.m.
On 12/07/2010 03:07 AM, ppluzhnikov@google.com wrote:
> 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.]
>   
Applied, thanks.

Paolo.

PS: Remember to always send libstdc++ patches to the libstdc++ mailing
list too.

Patch

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(),