GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

libstdc++: Fix -fno-exceptions support in testsuite_allocator.h

The libstdc++ testsuite now correctly handles code compiled without exception support by using __try/__catch blocks.

The libstdc++ testsuite now supports compilation with the -fno-exceptions flag. The testsuite_allocator.h header was modified to use __try and __catch instead of try and catch blocks, which are unavailable when exceptions are disabled. This allows the testsuite to run correctly in environments where exception handling is not enabled.

In Details

The testsuite_allocator.h header in libstdc++ uses exception handling. When compiling with -fno-exceptions, standard try/catch blocks are unavailable. This commit replaces those with __try/__catch to enable testing allocators without exception support.

For Context

C++ provides exception handling as a mechanism to deal with errors during program execution. However, exception handling can add overhead, and some environments may require code to be compiled without it. This commit ensures that the libstdc++ testsuite can be run in such environments by using compiler-specific alternatives to standard exception handling constructs.

Filed Under: libstdc++exceptionstestsuite