summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Globals.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Globals.h b/src/Globals.h
index c081c5998..bc868b637 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -35,11 +35,15 @@
// The CRT has a definition for this operator new that stores the debugging info for leak-finding later.
#endif
+ #define UNREACHABLE_INTRINSIC __assume(false)
+
#elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
#define abstract
+ #define UNREACHABLE_INTRINSIC __builtin_unreachable()
+
#else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
@@ -271,8 +275,12 @@ template class SizeChecker<UInt8, 1>;
#endif // else TEST_GLOBALS
-/** Use to mark code that should be impossible to reach. */
-#define UNREACHABLE(x) do { FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__); std::abort(); } while (false)
+// Use to mark code that should be impossible to reach.
+#ifdef NDEBUG
+ #define UNREACHABLE(x) UNREACHABLE_INTRINSIC
+#else
+ #define UNREACHABLE(x) ( FLOGERROR("Hit unreachable code: {0}, file {1}, line {2}", #x, __FILE__, __LINE__), std::abort(), 0)
+#endif