From 2f42773cd7bef8b9477f2f687efce270f2e922ae Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 5 Sep 2023 15:55:43 -0700 Subject: [PATCH] Fix error: cannot use 'throw' with exceptions disabled `mimalloc` should compile even if exceptions are disabled by the MSVC or GCC or Clang command-line options. --- src/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/alloc.c b/src/alloc.c index ffc1747d..fb4e25d6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -913,9 +913,13 @@ static bool mi_try_new_handler(bool nothrow) { #endif if (h==NULL) { _mi_error_message(ENOMEM, "out of memory in 'new'"); + #if defined(_CPPUNWIND) || defined(__cpp_exceptions) if (!nothrow) { throw std::bad_alloc(); } + #else + (void)nothrow; + #endif return false; } else {