From 5df16a36263000ede2bc818f4396b6968d9c0b62 Mon Sep 17 00:00:00 2001 From: Michael Park Date: Wed, 13 Sep 2017 16:09:27 -0700 Subject: [PATCH] Try using `__builtin_unreachable` instead. --- include/mpark/config.hpp | 4 ++++ include/mpark/variant.hpp | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) 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 }