From b79dcf147b9a8a2af74c9d14e21e90607eed8fd1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 20 Aug 2024 15:02:11 -0700 Subject: [PATCH] Fix emscripten; use minimal trap on all GCCs --- include/adobe/contract_checks.hpp | 2 +- test/minimal_configuration_tests.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/adobe/contract_checks.hpp b/include/adobe/contract_checks.hpp index c72d697..b4e07c7 100644 --- a/include/adobe/contract_checks.hpp +++ b/include/adobe/contract_checks.hpp @@ -7,7 +7,7 @@ // ADOBE_MINIMAL_TRAP(): followed with a semicolon, expands to a // minimal statement that stops the program. -#if defined(__clang__) || defined(__GNUC__) && __GNUC__ < 10 +#if !defined(__EMSCRIPTEN__) && (defined(__clang__) || defined(__GNUC__)) #define ADOBE_MINIMAL_TRAP() __builtin_trap() #elif defined(_MSC_VER) #define ADOBE_MINIMAL_TRAP() __debugbreak() diff --git a/test/minimal_configuration_tests.cpp b/test/minimal_configuration_tests.cpp index 19e4c9a..ac10496 100644 --- a/test/minimal_configuration_tests.cpp +++ b/test/minimal_configuration_tests.cpp @@ -8,3 +8,11 @@ TEST(MinimalConfigurationDeathTests, FailedChecksDie) EXPECT_PORTABLE_DEATH(ADOBE_POSTCONDITION(false), ""); EXPECT_PORTABLE_DEATH(ADOBE_INVARIANT(false), ""); } + +// ****** This should be the last test in the file. ********* +// +// For unknown reasons if the last test is a death test, under +// emscripten, the test fails even if the executable aborts. +#if defined(__EMSCRIPTEN__) +TEST(MinimalConfiguration, EmscriptenDummy) {} +#endif