mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
6d0ee60740
commit
eebaa9bfc5
8 changed files with 39 additions and 15 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue