[PATCH] libstdc++: Implement C++20 features for <sstream>

Jonathan Wakely jwakely@redhat.com
Thu Nov 5 13:33:30 GMT 2020


On 04/11/20 23:41 +0000, Jonathan Wakely wrote:
>On 04/11/20 21:45 +0000, Jonathan Wakely wrote:
>>On 04/11/20 12:43 -0800, Thomas Rodgers wrote:
>>>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97719
>>>
>>>>On Nov 4, 2020, at 11:54 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
>>>>
>>>>On 07/10/2020 18:55, Thomas Rodgers wrote:
>>>>>From: Thomas Rodgers <trodgers@redhat.com>
>>>>>New ctors and ::view() accessor for -
>>>>> * basic_stingbuf
>>>>> * basic_istringstream
>>>>> * basic_ostringstream
>>>>> * basic_stringstreamm
>>>>>New ::get_allocator() accessor for basic_stringbuf.
>>>>I found that this <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a0e4d7b44c544c84cffc7ff9c64b6f1af14fb08d> "libstdc++: Implement C++20 features for <sstream>" changed the behavior of
>>>>
>>>>>$ cat test.cc
>>>>>#include <iostream>
>>>>>#include <iterator>
>>>>>#include <sstream>
>>>>>int main() {
>>>>>std::stringstream s("a");
>>>>>std::istreambuf_iterator<char> i(s);
>>>>>if (i != std::istreambuf_iterator<char>()) std::cout << *i << '\n';
>>>>>}
>>>>>$ g++ -std=c++20 test.cc
>>>>>$ ./a.out
>>>>
>>>>from printing "a" to printing nothing.  (The `i != ...` comparison appears to change i from pointing at "a" to pointing to null, and returns false.)
>>>>
>>>>I ran into this when building LibreOffice, and I hope test.cc is a faithfully minimized reproducer.  However, I know little about std::istreambuf_iterator, so it may well be that the code isn't even valid.
>>>>
>>
>>I'm testing this patch.
>
>Tested powerpc64le-linux. Pushed now.

And this fixes some other bugs in the new constructors.

Tested powerpc64le-linux, pushed to trunk.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 28691 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201105/0bfb9a3c/attachment-0001.bin>


More information about the Libstdc++ mailing list