[v3 PATCH] basic_string spurious use of a default constructible allocator - LWG2788

Jonathan Wakely jwakely@redhat.com
Thu May 30 19:48:00 GMT 2019


On 27/05/19 11:53 +0100, Nina Dinka Ranns wrote:
>Tested on Linux x86_64
>basic_string spurious use of a default constructible allocator - LWG2788
>
>2019-05-27  Nina Dinka Ranns  <dinka.ranns@gmail.com>
>        basic_string spurious use of a default constructible allocator - LWG2788
>        * bits/basic_string.tcc:
>        (_M_replace_dispatch()): string temporary now constructed with
>the current allocator
>        * testsuite/21_strings/basic_string/allocator/char/lwg2788.cc: New
>        * testsuite/21_strings/basic_string/allocator/wchar_t/lwg2788.cc: New

Thanks!


>Index: libstdc++-v3/include/bits/basic_string.tcc
>===================================================================
>--- libstdc++-v3/include/bits/basic_string.tcc	(revision 271509)
>+++ libstdc++-v3/include/bits/basic_string.tcc	(working copy)
>@@ -381,7 +381,9 @@
> 			  _InputIterator __k1, _InputIterator __k2,
> 			  std::__false_type)
>       {
>-	const basic_string __s(__k1, __k2);
>+    // _GLIBCXX_RESOLVE_LIB_DEFECTS
>+    // 2788. unintentionally require a default constructible allocator

I've fixed the indentation of this comment.

>+	const basic_string __s(__k1, __k2, this->get_allocator());
> 	const size_type __n1 = __i2 - __i1;
> 	return _M_replace(__i1 - begin(), __n1, __s._M_data(),
> 			  __s.size());
>Index: libstdc++-v3/testsuite/20_util/nonesuch/nonesuch.cc
>===================================================================
>--- libstdc++-v3/testsuite/20_util/nonesuch/nonesuch.cc	(revision 271509)
>+++ libstdc++-v3/testsuite/20_util/nonesuch/nonesuch.cc	(nonexistent)

And dropped this part of the patch which spuriously removed an
unrelated file.

Tested powerpc64le-linux with both string ABIs.

The version I've committed is attached.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 6803 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190530/a3c28b99/attachment.bin>


More information about the Libstdc++ mailing list