From 491392a1ed14dcbbf4d45701b474028ea5882a55 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Mon, 13 Jun 2022 15:49:08 +0100 Subject: [PATCH] gh-91731: Don't define 'static_assert' in C++11 where is a keyword to avoid UB (GH-93700) (cherry picked from commit 65ff27c7d30b84655bf8caf6e396c65485708148) Co-authored-by: Pablo Galindo Salgado --- Include/pymacro.h | 2 ++ .../next/C API/2022-06-10-23-41-48.gh-issue-91731.fhYUQG.rst | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/C API/2022-06-10-23-41-48.gh-issue-91731.fhYUQG.rst diff --git a/Include/pymacro.h b/Include/pymacro.h index b959eeb3f58b35..90ad8f07844460 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -12,8 +12,10 @@ // static_assert is defined in glibc from version 2.16. Before it requires // compiler support (gcc >= 4.6) and is called _Static_assert. +// In C++ 11 static_assert is a keyword, redefining is undefined behaviour. #if (defined(__GLIBC__) \ && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 16)) \ + && !(defined(__cplusplus) && __cplusplus >= 201103L) \ && !defined(static_assert)) # define static_assert _Static_assert #endif diff --git a/Misc/NEWS.d/next/C API/2022-06-10-23-41-48.gh-issue-91731.fhYUQG.rst b/Misc/NEWS.d/next/C API/2022-06-10-23-41-48.gh-issue-91731.fhYUQG.rst new file mode 100644 index 00000000000000..185671ca4fcfb1 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2022-06-10-23-41-48.gh-issue-91731.fhYUQG.rst @@ -0,0 +1,3 @@ +Avoid defining the ``static_assert`` when compiling with C++ 11, where this +is a keyword and redefining it can lead to undefined behavior. Patch by +Pablo Galindo pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy