summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/unreachable.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/compat/unreachable.hpp b/compat/unreachable.hpp
new file mode 100644
index 00000000..bb029b6d
--- /dev/null
+++ b/compat/unreachable.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+namespace floormat {
+
+[[noreturn]] inline void unreachable()
+{
+#if defined __GNUC__
+ __builtin_unreachable();
+#elif defined _MSC_VER
+ __assume(false);
+#else
+ *(volatile int*)0 = 0;
+#endif
+}
+
+} // namespace floormat