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:
Serhiy Storchaka 2020-03-09 20:49:52 +02:00 committed by GitHub
parent 6d0ee60740
commit eebaa9bfc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 15 deletions

View file

@ -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