summaryrefslogtreecommitdiffhomepage
path: root/compat/unreachable.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-16 15:08:58 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-16 15:08:58 +0200
commit7f26f8fd7f3171eda4a194d8fd5ffcbba80dd31f (patch)
treeb07448b1c42a43cc1dc98353555776c7193fb0c7 /compat/unreachable.hpp
parentacc3ffe2324d665ed5e62a60ac914d8c01eb828e (diff)
a
Diffstat (limited to 'compat/unreachable.hpp')
-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