jemalloc/include/jemalloc
lexprfuncall 1a15fe33a4
Replace std::__throw_bad_alloc call with standard C++ (#2900)
* Replace std::__throw_bad_alloc call with standard C++

Since December of 2025, std::__throw_bad_alloc is no longer visible
through #include <new> causing jemalloc build failures with gcc 16.
As far as I can tell, all std::__throw_bad_alloc did was arrange to
raise a std::bad_alloc exception if exceptions are enabled.  I am not
sure whether its usage was truly meaningful in jemalloc since the call
is wrapped in a try catch and any usage of try catch is considered an
error when compiling with -fno-exceptions on gcc, at least.

This change adds a check to configure.ac that determines whether
exceptions are enabled by compiling a simple try catch that raises a
std::bad_alloc exception.  If that test succeeds, the macro
JEMALLOC_HAVE_CXX_EXCEPTIONS is defined, and jemalloc will raise an
exception.  Otherwise, we call std::terminate() to abort.

This was tested on FreeBSD with the gcc16 port with and without exceptions
enabled.

* Replace std::set_new_handler calls with std::get_new_handler

Previously, std::set_new_handler was used as a workaround for
compilers with only partial support for C++11.  Now that C++14 is a
requirement to enable C++ support, we can assume std::get_new_handler
is available.
2026-04-27 11:50:27 -07:00
..
internal Replace std::__throw_bad_alloc call with standard C++ (#2900) 2026-04-27 11:50:27 -07:00
jemalloc.sh Move `extern "C" specifications for C++ to where they are needed 2025-03-31 10:41:51 -07:00
jemalloc_defs.h.in Disable config from file or envvar with build flag 2025-02-05 15:01:50 -08:00
jemalloc_macros.h.in Make JEMALLOC_CXX_THROW definition compatible with newer C++ versions 2024-06-13 11:03:05 -07:00
jemalloc_mangle.sh jemalloc_mangle.sh: set sh in strict mode 2017-12-11 23:35:20 -08:00
jemalloc_protos.h.in Move `extern "C" specifications for C++ to where they are needed 2025-03-31 10:41:51 -07:00
jemalloc_rename.sh Fix name mangling for stress tests. 2014-01-16 17:38:01 -08:00
jemalloc_typedefs.h.in Move `extern "C" specifications for C++ to where they are needed 2025-03-31 10:41:51 -07:00