From 944ec1ab8acfc38137f716d85ceb7f896a39f852 Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 2 Mar 2024 15:47:07 -0800 Subject: [PATCH] Fix error: cannot use 'throw' with exceptions disabled #815, by @sergio-nsk --- src/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/alloc.c b/src/alloc.c index b17fdbdc..484a3e5b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -908,9 +908,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) // exceptions are not always enabled if (!nothrow) { throw std::bad_alloc(); } + #else + MI_UNUSED(nothrow); + #endif return false; } else {