]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41875: Use __builtin_unreachable when possible (GH-22433)
authorDong-hee Na <donghee.na92@gmail.com>
Mon, 28 Sep 2020 20:41:23 +0000 (05:41 +0900)
committerGitHub <noreply@github.com>
Mon, 28 Sep 2020 20:41:23 +0000 (05:41 +0900)
Include/pymacro.h
Misc/NEWS.d/next/Build/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst [new file with mode: 0644]

index 856cae774d61c765ebeb0d75f23cd3deb31b6bc6..202b936d964f00dec2f7cb8a3fc993f1bd6cfc85 100644 (file)
         "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)
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#  define Py_UNREACHABLE() __builtin_unreachable()
+#elif defined(__clang__) || defined(__INTEL_COMPILER)
 #  define Py_UNREACHABLE() __builtin_unreachable()
 #elif defined(_MSC_VER)
 #  define Py_UNREACHABLE() __assume(0)
diff --git a/Misc/NEWS.d/next/Build/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst b/Misc/NEWS.d/next/Build/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst
new file mode 100644 (file)
index 0000000..3e409ec
--- /dev/null
@@ -0,0 +1,2 @@
+Update :c:macro:`Py_UNREACHABLE` to use __builtin_unreachable() if only the
+compiler is able to use it. Patch by Dong-hee Na.