From 8af0cbed8c336b9bfaaac359e52d6b1b396ed489 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 6 Apr 2025 14:52:08 +0100 Subject: Add portable unreachable macro, just for fun This isn't useful to us at all, but might be useful to someone else. I always try to write code for multiple compilers for this reason, even if SST ultimately still requires Clang. --- src/langext.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/langext.h b/src/langext.h index 8d3ee6e..0a17cb2 100644 --- a/src/langext.h +++ b/src/langext.h @@ -26,8 +26,9 @@ #define assume(x) ((void)(__assume(x), 0)) #define cold __declspec(noinline) #else -#define unreachable ((void)(0)) // might still give some warnings, but too bad -#define assume(x) ((void)0) +static inline _Noreturn void _invoke_ub(void) {} +#define unreachable (_invoke_ub()) +#define assume(x) ((void)(!!(x) || (_invoke_ub(), 0))) #define cold #endif #endif -- cgit v1.2.3-54-g00ecf