From c3694a15fa68fe8e7da5a0da7d478b2dfd5fd9dd Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 28 Sep 2020 21:56:56 +0900 Subject: [PATCH 1/2] bpo-41875: Use __builtin_unreachable when possible --- Include/pymacro.h | 4 +++- .../next/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst diff --git a/Include/pymacro.h b/Include/pymacro.h index 856cae774d61c7..202b936d964f00 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -118,7 +118,9 @@ "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/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst b/Misc/NEWS.d/next/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst new file mode 100644 index 00000000000000..3e409ec2e7c202 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst @@ -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. From 93b9c55d63324ff92cc8b2f700651446b39a89b3 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 29 Sep 2020 01:15:12 +0900 Subject: [PATCH 2/2] bpo-41875: Update NEWS.d --- .../{C API => Build}/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{C API => Build}/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst (100%) diff --git a/Misc/NEWS.d/next/C API/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 similarity index 100% rename from Misc/NEWS.d/next/C API/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst rename to Misc/NEWS.d/next/Build/2020-09-28-21-56-51.bpo-38249.uzMCaZ.rst