On Wed, Jun 17, 2026 at 02:44:35PM +0100, Jonathan Wakely wrote:
> On Wed, 17 Jun 2026 at 14:10, Patrick Palka <[email protected]> wrote:
> >
> > On Wed, 17 Jun 2026, Patrick Palka wrote:
> >
> > > On Mon, 8 Jun 2026, Marek Polacek wrote:
> > >
> > > > Bootstrapped/regtested on ppc64le-pc-linux-gnu, ok for trunk?
> > > >
> > > > -- >8 --
> > > > r15-2650 removed noexcept from non-const std::basic_string::data()
> > > > in bits/cow_string.h, but the explicit instantiations in string-inst.cc
> > > > kept their noexcept.
> > > > [except.spec] says that in an explicit instantiation
> > > > a noexcept-specifier may be specified, but is not required, but when it
> > > > is specified, it must be the same as the exception specification of all
> > > > other declarations of that function.  So I think we should just remove 
> > > > it.
> 
> Does GCC fail to diagnose the 'noexcept' for the COW instantiation?

Right now yes.  But I have a patch for it:
<https://gcc.gnu.org/pipermail/gcc-patches/2026-June/719735.html>
which is how I found this.

> > >
> > > LGTM.  Alternatively we could conditionally add the noexcept depending
> > > on whether the C++11 or COW std::string is in effect but it's simpler to
> > > just unconditionally omit it.
> > >
> > > >
> > > > libstdc++-v3/ChangeLog:
> > > >
> > > >     * src/c++17/string-inst.cc (basic_string::data): Remove noexcept.
> > > > ---
> > > >  libstdc++-v3/src/c++17/string-inst.cc | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/libstdc++-v3/src/c++17/string-inst.cc 
> > > > b/libstdc++-v3/src/c++17/string-inst.cc
> > > > index ac52adaa7b5..e9ef1bfd0dc 100644
> > > > --- a/libstdc++-v3/src/c++17/string-inst.cc
> > > > +++ b/libstdc++-v3/src/c++17/string-inst.cc
> > > > @@ -42,14 +42,14 @@ template 
> > > > basic_string<char>::basic_string(__sv_wrapper, const allocator_type&);
> > > >  template basic_string<char>::__sv_wrapper::__sv_wrapper(string_view);
> > > >  template string_view 
> > > > basic_string<char>::_S_to_string_view(string_view);
> > > >  template basic_string<char>::operator string_view() const noexcept;
> >
> > Should we also remove the noexcept here too, for consistency?
> 
> I don't have an opinion on that, either way is fine by me.
> 
> > > > -template char* basic_string<char>::data() noexcept;
> > > > +template char* basic_string<char>::data();
> 
> I was wondering if we should have a comment here explaining why we
> don't say noexcept, but I don't think it's likely that anybody will
> try to add it back. So we don't need a comment.
> 
> OK for trunk (with or without removing noexcept on both the string
> view conversion operators).

Thanks, pushed as-is.  We'll give an error if they become out of sync again.

Marek

Reply via email to