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.

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;
> -template char* basic_string<char>::data() noexcept;
> +template char* basic_string<char>::data();
>  
>  #ifdef _GLIBCXX_USE_WCHAR_T
>  template basic_string<wchar_t>::basic_string(__sv_wrapper, const 
> allocator_type&);
>  template basic_string<wchar_t>::__sv_wrapper::__sv_wrapper(wstring_view);
>  template wstring_view basic_string<wchar_t>::_S_to_string_view(wstring_view);
>  template basic_string<wchar_t>::operator wstring_view() const noexcept;
> -template wchar_t* basic_string<wchar_t>::data() noexcept;
> +template wchar_t* basic_string<wchar_t>::data();
>  #endif
>  
>  _GLIBCXX_END_NAMESPACE_VERSION
> 
> base-commit: 32bbd8849a550ad6f936636476c3ab9be8a58807
> -- 
> 2.54.0
> 
> 

Reply via email to