diff --git a/include/mpark/config.hpp b/include/mpark/config.hpp index 7e802f807..b79017df2 100644 --- a/include/mpark/config.hpp +++ b/include/mpark/config.hpp @@ -30,6 +30,10 @@ #define MPARK_BUILTIN_ADDRESSOF #endif +#if __has_builtin(__builtin_unreachable) +#define MPARK_BUILTIN_UNREACHABLE +#endif + #if __has_builtin(__type_pack_element) #define MPARK_TYPE_PACK_ELEMENT #endif diff --git a/include/mpark/variant.hpp b/include/mpark/variant.hpp index 00d3cf67c..8f9c17c6a 100644 --- a/include/mpark/variant.hpp +++ b/include/mpark/variant.hpp @@ -247,13 +247,9 @@ namespace mpark { #ifdef MPARK_EXCEPTIONS throw bad_variant_access{}; #else -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winvalid-noreturn" -#endif std::terminate(); -#ifdef __clang__ -#pragma clang diagnostic pop +#ifdef MPARK_BUILTIN_UNREACHABLE + __builtin_unreachable(); #endif #endif }