This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Fix libstdc++/14245


Hi,

after a little bit of struggle ;), I came to the conclusion that
submitter is right. In a nut shell, besides technical points about
sophisticated allocators, the issue is that we should always pass to
_Rep::_M_grab as its first argument the allocator actually used by
the string, otherwise, _S_create (called by _M_clone) may end up
allocating memory via an allocator different from that of the string:
no good.

Tested x86-linux. If nobody objects, will commit early tomorrow to
mainline.

Paolo.

///////////////
2004-02-25  Chavdar Botev  <cbotev@yahoo.com>

	PR libstdc++/14245
	* include/bits/basic_string.tcc
	(basic_string::basic_string(const basic_string&)): Pass to
	_Rep::_M_grab the actual allocator of the string being constructed
	not the default constructed one. 
diff -urN libstdc++-v3-orig/include/bits/basic_string.tcc libstdc++-v3/include/bits/basic_string.tcc
--- libstdc++-v3-orig/include/bits/basic_string.tcc	2004-02-08 18:11:07.000000000 +0100
+++ libstdc++-v3/include/bits/basic_string.tcc	2004-02-25 18:34:37.000000000 +0100
@@ -178,8 +178,9 @@
   template<typename _CharT, typename _Traits, typename _Alloc>
     basic_string<_CharT, _Traits, _Alloc>::
     basic_string(const basic_string& __str)
-    : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(), __str.get_allocator()),
-		 __str.get_allocator())
+    : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
+					  __str.get_allocator()),
+		  __str.get_allocator())
     { }
 
   template<typename _CharT, typename _Traits, typename _Alloc>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]