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.


>           }
> +#endif
>
>         return p;
>        }
> @@ -394,16 +398,20 @@ namespace __gnu_test
>           { return r; }
>         else
>           {
> +#if __cpp_exceptions
>             try
> +#endif
>               {
>                 get_map().insert(map_type::value_type(
>                       reinterpret_cast<void*>(r.ptr), personality));
>               }
> +#if __cpp_exceptions
>             catch(...)
>               {
>                 AllocTraits::deallocate(*this, r.ptr, r.count);
>                 __throw_exception_again;
>               }
> +#endif
>             return r;
>           }
>        }
> --
> 2.54.0.rc1.54.g60f07c4f5c
>

Reply via email to