summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-03-09 18:49:52 (GMT)
committerGitHub <noreply@github.com>2020-03-09 18:49:52 (GMT)
commiteebaa9bfc593d5a46b293c1abd929fbfbfd28199 (patch)
tree9ba0bbaba8116eb71d0b80f11b586fe063aadbe5 /Include
parent6d0ee60740f2862a878f009671b1aaa75aeb0c2a (diff)
downloadcpython-eebaa9bfc593d5a46b293c1abd929fbfbfd28199.zip
cpython-eebaa9bfc593d5a46b293c1abd929fbfbfd28199.tar.gz
cpython-eebaa9bfc593d5a46b293c1abd929fbfbfd28199.tar.bz2
bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include')
-rw-r--r--Include/pymacro.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h
index c080fb1..856cae7 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -101,7 +101,7 @@
#endif
#if defined(RANDALL_WAS_HERE)
-#define Py_UNREACHABLE() \
+# define Py_UNREACHABLE() \
Py_FatalError( \
"If you're seeing this, the code is in what I thought was\n" \
"an unreachable state.\n\n" \
@@ -113,13 +113,17 @@
"I'm so sorry.\n" \
"https://xkcd.com/2200")
#elif defined(Py_DEBUG)
-#define Py_UNREACHABLE() \
+# define Py_UNREACHABLE() \
Py_FatalError( \
"We've reached an unreachable state. Anything is possible.\n" \
"The limits were in our heads all along. Follow your dreams.\n" \
"https://xkcd.com/2200")
+#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
+# define Py_UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+# define Py_UNREACHABLE() __assume(0)
#else
-#define Py_UNREACHABLE() \
+# define Py_UNREACHABLE() \
Py_FatalError("Unreachable C code path reached")
#endif