summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-02-20 17:24:13 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-02-20 18:46:02 +0100
commit81e299f00ce3df587166ccc94f5997555cce5210 (patch)
treed5954c7f5756b67b2c6c1f7c6f2b635f5337eef2 /src/Globals.h
parentClang 7? (diff)
downloadcuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar.gz
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar.bz2
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar.lz
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar.xz
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.tar.zst
cuberite-81e299f00ce3df587166ccc94f5997555cce5210.zip
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