On Tue, Jun 10, 2025 at 12:37 PM Jonathan Wakely <jwak...@redhat.com> wrote:
> The std::basic_stringbuf::get_allocator() member is only available for > the SSO std::string ABI. > > libstdc++-v3/ChangeLog: > > * testsuite/27_io/basic_istringstream/cons/char/string_view.cc: > Only check get_allocator() for new string ABI. > * testsuite/27_io/basic_ostringstream/cons/char/string_view.cc: > Likewise. > * testsuite/27_io/basic_stringbuf/cons/char/string_view.cc: > Likewise. > * testsuite/27_io/basic_stringstream/cons/char/string_view.cc: > Likewise. > --- > > Tested x86_64-linux. > LGTM. > > .../27_io/basic_istringstream/cons/char/string_view.cc | 6 ++++++ > .../27_io/basic_ostringstream/cons/char/string_view.cc | 6 ++++++ > .../27_io/basic_stringbuf/cons/char/string_view.cc | 6 ++++++ > .../27_io/basic_stringstream/cons/char/string_view.cc | 6 ++++++ > 4 files changed, 24 insertions(+) > > diff --git > a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/string_view.cc > b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/string_view.cc > index 27f65aa94375..f25b538b2fa8 100644 > --- > a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/string_view.cc > +++ > b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/string_view.cc > @@ -151,20 +151,26 @@ void test03() > alloc_type a{1}; > { > istringstream_with_alloc<alloc_type> istr(cstr, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( istr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{istr.str()} == cstr ); > VERIFY( istr.get() == cstr.s[0] ); > } > { > istringstream_with_alloc<alloc_type> istr(cstr, std::ios::in, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( istr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{istr.str()} == cstr ); > VERIFY( istr.get() == cstr.s[0] ); > VERIFY( istr.rdbuf()->sputc('X') != 'X' ); > } > { > istringstream_with_alloc<alloc_type> istr(cstr, std::ios::out, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( istr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{istr.str()} == cstr ); > VERIFY( istr.get() == cstr.s[0] ); > VERIFY( istr.rdbuf()->sputc('X') == 'X' ); > diff --git > a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/string_view.cc > b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/string_view.cc > index 731e97e4aa2c..6279c19e54c5 100644 > --- > a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/string_view.cc > +++ > b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/string_view.cc > @@ -149,21 +149,27 @@ void test03() > alloc_type a{1}; > { > ostringstream_with_alloc<alloc_type> ostrstr(cstr, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( ostrstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{ostrstr.str()} == cstr ); > VERIFY( ostrstr.rdbuf()->sgetc() == ostringstream::traits_type::eof() > ); > VERIFY( ostrstr.put('X').good() ); > } > { > ostringstream_with_alloc<alloc_type> ostrstr(cstr, std::ios::in, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( ostrstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{ostrstr.str()} == cstr ); > VERIFY( ostrstr.rdbuf()->sgetc() == cstr.s[0]); > VERIFY( ostrstr.put('X').good() ); > } > { > ostringstream_with_alloc<alloc_type> ostrstr(cstr, std::ios::out, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( ostrstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{ostrstr.str()} == cstr ); > VERIFY( ostrstr.rdbuf()->sgetc() == ostringstream::traits_type::eof() > ); > VERIFY( ostrstr.put('Y').rdstate() == ostrstr.goodbit ); > diff --git > a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/string_view.cc > b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/string_view.cc > index 7843269c48fd..14278b3faf83 100644 > --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/string_view.cc > +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/string_view.cc > @@ -161,20 +161,26 @@ void test03() > alloc_type a{1}; > { > stringbuf_with_alloc<alloc_type> sbuf(cstr, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( sbuf.get_allocator() == a ); > +#endif > VERIFY( string_view{sbuf.str()} == cstr ); > VERIFY( sbuf.sgetc() == cstr.s[0] ); > } > { > stringbuf_with_alloc<alloc_type> sbuf(cstr, std::ios::in, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( sbuf.get_allocator() == a ); > +#endif > VERIFY( string_view{sbuf.str()} == cstr ); > VERIFY( sbuf.sgetc() == cstr.s[0] ); > VERIFY( sbuf.sputc('X') == stringbuf::traits_type::eof() ); > } > { > stringbuf_with_alloc<alloc_type> sbuf(cstr, std::ios::out, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( sbuf.get_allocator() == a ); > +#endif > VERIFY( string_view{sbuf.str()} == cstr ); > VERIFY( sbuf.sputc('X') == 'X' ); > VERIFY( sbuf.sgetc() == stringbuf::traits_type::eof() ); > diff --git > a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/string_view.cc > b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/string_view.cc > index 72085230442f..1c9eceaa55cf 100644 > --- > a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/string_view.cc > +++ > b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/string_view.cc > @@ -160,20 +160,26 @@ void test03() > alloc_type a{1}; > { > stringstream_with_alloc<alloc_type> strstr(cstr, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( strstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{strstr.str()} == cstr ); > VERIFY( strstr.get() == cstr.s[0] ); > } > { > stringstream_with_alloc<alloc_type> strstr(cstr, std::ios::in, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( strstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{strstr.str()} == cstr ); > VERIFY( strstr.get() == cstr.s[0] ); > VERIFY( strstr.put('X').rdstate() == strstr.badbit ); > } > { > stringstream_with_alloc<alloc_type> strstr(cstr, std::ios::out, a); > +#if _GLIBCXX_USE_CXX11_ABI > VERIFY( strstr.rdbuf()->get_allocator() == a ); > +#endif > VERIFY( string_view{strstr.str()} == cstr ); > VERIFY( strstr.put('X').good() ); > VERIFY( strstr.get() == stringstream::traits_type::eof()); > -- > 2.49.0 > >