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...
>
> libstdc++-v3/ChangeLog:
>
> * testsuite/util/testsuite_allocator.h
> (uneq_allocator::allocate_at_least): Guard try/catch with
> __cpp_exceptions.
> ---
> libstdc++-v3/testsuite/util/testsuite_allocator.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> index 27372a97161d..cb8e9bc01bb9 100644
> --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
> +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
> @@ -394,16 +394,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
>
>