On Thu, 28 May 2026 at 15:24, Patrick Palka <[email protected]> wrote:
>
> On Thu, 28 May 2026, Jonathan Wakely wrote:
>
> > On Thu, 28 May 2026 at 15:13, Patrick Palka <[email protected]> wrote:
> > >
> > > On Thu, 28 May 2026, Patrick Palka wrote:
> > >
> > > > On Thu, 28 May 2026, Jonathan Wakely wrote:
> > > >
> > > > > On Thu, 28 May 2026 at 15:05, Jonathan Wakely <[email protected]>
> > > > > wrote:
> > > > > >
> > > > > > On Thu, 28 May 2026 at 14:41, Patrick Palka <[email protected]>
> > > > > > wrote:
> > > > > > >
> > > > > > > On Thu, 28 May 2026, Patrick Palka wrote:
> > > > > > >
> > > > > > > > OK for trunk?
> > > > > > > >
> > > > > > > > -- >8 --
> > > > > > > >
> > > > > > > > This fixes the error
> > > > > > > >
> > > > > > > > .../testsuite_allocator.h:402:13: error: exception handling
> > > > > > > > disabled, use ‘-fexceptions’ to enable
> > > > > > > > 402 | catch(...)
> > > > > > > > | ^~~~~
> > > > > > > >
> > > > > > > > seen when running some C++23 library tests with -fno-exceptions.
> > > > > > >
> > > > > > > Huh, I wonder why we complain about this unguarded catch but not
> > > > > > > about
> > > > > > > the one inside uneq_allocator::allocate a few lines above...
> > > > > >
> > > > > > I was just wondering that ...
> > > > >
> > > > > Maybe it only complains about the members that are instantiated?
> > > > >
> > > > > Both functions need the same fix, I think.
> > > >
> > > > Yeah, I think you're right. I'm surprised we haven't run into this for
> > > > for ::allocate which was added in 2006.
> > >
> > > Changes in v2:
> > >
> > > - Also guard the try/catch in ::allocate.
> > >
> > > -- >8 --
> > >
> > > Subject: [PATCH v2] libstdc++: Fix -fno-exceptions support in
> > > testsuite_allocator.h
> > >
> > > This fixes the error
> > >
> > > .../testsuite_allocator.h:402:13: error: exception handling disabled, use
> > > ‘-fexceptions’ to enable
> > > 402 | catch(...)
> > > | ^~~~~
> > >
> > > seen when running some C++23 library tests with -fno-exceptions.
> > >
> > > libstdc++-v3/ChangeLog:
> > >
> > > * testsuite/util/testsuite_allocator.h
> > > (uneq_allocator::allocate): Guard try/catch with __cpp_exceptions.
> > > (uneq_allocator::allocate_at_least): Likewise.
> > > ---
> > > libstdc++-v3/testsuite/util/testsuite_allocator.h | 8 ++++++++
> > > 1 file changed, 8 insertions(+)
> > >
> > > diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> > > b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> > > index 27372a97161d..5b2f02d8042f 100644
> > > --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> > > +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> > > @@ -369,16 +369,20 @@ namespace __gnu_test
> > > if (std::__is_constant_evaluated())
> > > return p;
> > >
> > > +#if __cpp_exceptions
> > > try
> > > +#endif
> > > {
> > >
> > > get_map().insert(map_type::value_type(reinterpret_cast<void*>(p),
> > > personality));
> > > }
> > > +#if __cpp_exceptions
> > > catch(...)
> > > {
> > > AllocTraits::deallocate(*this, p, n);
> > > __throw_exception_again;
> >
> > This could just be 'throw' now, in both places.
> >
> > OK with or without that change.
>
> Ah, I could've sworn we had -fno-exception safe macros for
> try/catch/throw, but I couldn't find them in c++config. Agreed it
> doesn't make sense to mix the __throw_exception_again macro with
> __cpp_exceptions.
Yeah, we have them in libsupc++/exception_defines.h
That won't help your flat_map patch, because __try isn't valid outside
block scope, so can't be used for function-try blocks.
>
> Do you prefer using __cpp_exceptions, or the
> __try/__catch/__throw_exception_again macros like so?
> I slightly prefer the latter.
Agreed, OK to push that. Thanks.
>
> -- >8 --
>
> Subject: [PATCH] libstdc++: Fix -fno-exceptions support in
> testsuite_allocator.h
>
> This fixes the error
>
> .../testsuite_allocator.h:402:13: error: exception handling disabled, use
> '-fexceptions' to enable
> 402 | catch(...)
> | ^~~~~
>
> seen when running some C++23 library tests with -fno-exceptions.
>
> libstdc++-v3/ChangeLog:
>
> * testsuite/util/testsuite_allocator.h
> (uneq_allocator::allocate): Use __try/__catch instead.
> (uneq_allocator::allocate_at_least): Likewise.
> ---
> libstdc++-v3/testsuite/util/testsuite_allocator.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> index 27372a97161d..3a9ae0de5853 100644
> --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> @@ -369,12 +369,12 @@ namespace __gnu_test
> if (std::__is_constant_evaluated())
> return p;
>
> - try
> + __try
> {
> get_map().insert(map_type::value_type(reinterpret_cast<void*>(p),
> personality));
> }
> - catch(...)
> + __catch(...)
> {
> AllocTraits::deallocate(*this, p, n);
> __throw_exception_again;
> @@ -394,12 +394,12 @@ namespace __gnu_test
> { return r; }
> else
> {
> - try
> + __try
> {
> get_map().insert(map_type::value_type(
> reinterpret_cast<void*>(r.ptr), personality));
> }
> - catch(...)
> + __catch(...)
> {
> AllocTraits::deallocate(*this, r.ptr, r.count);
> __throw_exception_again;
> --
> 2.54.0.rc1.54.g60f07c4f5c