Re: [libcxx] r309838 - Fix PR33727: std::basic_stringbuf only works with DefaultConstructible allocators. Thanks to Jonathan Wakely for the report and suggested fix

2017-08-07 Thread Hans Wennborg via cfe-commits
On Wed, Aug 2, 2017 at 10:31 AM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Wed Aug  2 10:31:09 2017
> New Revision: 309838
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309838=rev
> Log:
> Fix PR33727: std::basic_stringbuf only works with DefaultConstructible 
> allocators. Thanks to Jonathan Wakely for the report and suggested fix
>
> Modified:
> libcxx/trunk/include/sstream
> 
> libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Merged to 5.0 in r310287.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r309838 - Fix PR33727: std::basic_stringbuf only works with DefaultConstructible allocators. Thanks to Jonathan Wakely for the report and suggested fix

2017-08-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug  2 10:31:09 2017
New Revision: 309838

URL: http://llvm.org/viewvc/llvm-project?rev=309838=rev
Log:
Fix PR33727: std::basic_stringbuf only works with DefaultConstructible 
allocators. Thanks to Jonathan Wakely for the report and suggested fix

Modified:
libcxx/trunk/include/sstream

libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Modified: libcxx/trunk/include/sstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/sstream?rev=309838=309837=309838=diff
==
--- libcxx/trunk/include/sstream (original)
+++ libcxx/trunk/include/sstream Wed Aug  2 10:31:09 2017
@@ -249,7 +249,8 @@ basic_stringbuf<_CharT, _Traits, _Alloca
 template 
 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const 
string_type& __s,
  ios_base::openmode __wch)
-: __hm_(0),
+: __str_(__s.get_allocator()),
+  __hm_(0),
   __mode_(__wch)
 {
 str(__s);

Modified: 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp?rev=309838=309837=309838=diff
==
--- 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 Wed Aug  2 10:31:09 2017
@@ -18,6 +18,16 @@
 #include 
 #include 
 
+template
+struct NoDefaultAllocator : std::allocator
+{
+  template struct rebind { using other = NoDefaultAllocator; };
+  NoDefaultAllocator(int id) : id(id) { }
+  template NoDefaultAllocator(const NoDefaultAllocator& a) : 
id(a.id) { }
+  int id;
+};
+
+
 int main()
 {
 {
@@ -46,4 +56,13 @@ int main()
 ss << i << ' ' << 123;
 assert(ss.str() == L"456 1236 ");
 }
+{ // This is https://bugs.llvm.org/show_bug.cgi?id=33727
+   typedef std::basic_string    S;
+   typedef std::basic_stringbuf SB;
+
+   S s(NoDefaultAllocator(1));
+   SB sb(s);
+   //  This test is not required by the standard, but *where else* 
could it get the allocator?
+   assert(sb.str().get_allocator() == s.get_allocator());
+}
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits