Skip to content

Commit 8e3132d

Browse files
committed
gh-91731: Don't define 'static_assert' in C++11 where is a keyword to avoid UB
1 parent 8136606 commit 8e3132d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Include/pymacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// compiler support (gcc >= 4.6) and is called _Static_assert.
1515
#if (defined(__GLIBC__) \
1616
&& (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 16)) \
17-
&& !defined(static_assert))
17+
&& !defined(static_assert) && !(defined(__cplusplus) && __cplusplus >= 201103L))
1818
# define static_assert _Static_assert
1919
#endif
2020

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Avoid defining the ``static_assert`` when compiling with C++ 11, where this
2+
is a keyword and redefining it can lead to undefined behavior. Patch by
3+
Pablo Galindo

0 commit comments

Comments
 (0)