diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 8bf0633fb..f0f7dd571 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -26,7 +26,8 @@ template #if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(EXCEPTIONS) throw std::forward(exception); #else - (void)exception; + // Forward the exception (even if unused) and abort + std::forward(exception); std::abort(); #endif } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 94768c22d..8c7163aaf 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2392,7 +2392,8 @@ template #if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(EXCEPTIONS) throw std::forward(exception); #else - (void)exception; + // Forward the exception (even if unused) and abort + std::forward(exception); std::abort(); #endif }