From 12e54665142c771a43f9365474254232764442f6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 5 Apr 2022 02:23:06 -0700 Subject: [PATCH 1/3] Support `-fno-exceptions` --- src/alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index cd4afa1e..2c2a5840 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -802,9 +802,11 @@ static bool mi_try_new_handler(bool nothrow) { #endif if (h==NULL) { _mi_error_message(ENOMEM, "out of memory in 'new'"); - if (!nothrow) { +#ifdef __EXCEPTIONS throw std::bad_alloc(); - } +#else + abort(); +#endif return false; } else { From 5a4f0d3cb4f76fa1d148c981c152598fcc28b5ad Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 5 Apr 2022 02:23:06 -0700 Subject: [PATCH 2/3] Support `-fno-exceptions` --- src/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/alloc.c b/src/alloc.c index cd4afa1e..5a89831a 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -803,7 +803,11 @@ static bool mi_try_new_handler(bool nothrow) { if (h==NULL) { _mi_error_message(ENOMEM, "out of memory in 'new'"); if (!nothrow) { +#ifdef __EXCEPTIONS throw std::bad_alloc(); +#else + abort(); +#endif } return false; } From 4d62cbde3a5ac8a70c8d6abc1d5441a086cec348 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 31 May 2022 22:06:17 -0700 Subject: [PATCH 3/3] Address feedback --- src/alloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 5a89831a..c0940088 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -803,11 +803,11 @@ static bool mi_try_new_handler(bool nothrow) { if (h==NULL) { _mi_error_message(ENOMEM, "out of memory in 'new'"); if (!nothrow) { -#ifdef __EXCEPTIONS - throw std::bad_alloc(); -#else - abort(); -#endif + #if defined(__GNUC__) && !defined(__EXCEPTIONS) + abort(); + #else + throw std::bad_alloc(); + #endif } return false; }