Repository navigation
Build fails with glibc 2.13 after static_assert fallback regression #160704
Copy link
Copy link
Closed
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Building CPython 3.15.2 against glibc 2.13 fails with an implicit declaration of static_assert.
gcc -pthread -c -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I/usr/local/src/python/Include/internal -I/usr/local/src/python/Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I/usr/local/src/python/Include -DPy_BUILD_CORE -o Objects/longobject.o /usr/local/src/python/Objects/longobject.c
In file included from /usr/local/src/python/Include/Python.h:70,
from /usr/local/src/python/Objects/longobject.c:5:
/usr/local/src/python/Include/internal/pycore_bitutils.h: In function '_Py_popcount32':
/usr/local/src/python/Include/pymacro.h:175:13: error: implicit declaration of function 'static_assert' [-Wimplicit-function-declaration]
175 | static_assert((cond), #cond); \
| ^~~~~~~~~~~~~
/usr/local/src/python/Include/internal/pycore_bitutils.h:100:5: note: in expansion of macro 'Py_BUILD_ASSERT'
100 | Py_BUILD_ASSERT(sizeof(x) <= sizeof(unsigned int));
| ^~~~~~~~~~~~~~~
make: *** [Makefile:3407: Objects/longobject.o] Error 1
This is a regression introduced by #160376 and backported to 3.15 in #160437. The change in Include/pymacro.h makes the static_assert fallback conditional on:
Lines 27 to 31 in c436e8d
| #if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \ | |
| && !defined(_Py_STDC_VERSION) \ | |
| && _Py_STDC_VERSION >= 201112L && _Py_STDC_VERSION <= 201710L | |
| # define static_assert _Static_assert | |
| #endif |
The negated !defined(_Py_STDC_VERSION) condition can never be true in standard C and is very likely a typo.
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gh-160704: Restore C11-C17 `static_assert` fallback (GH-160705)
encukou commentedon Oct 28, 2026
Oops!
Thank you for the catch, @ZhongRuoyu!
[3.15] gh-160704: Restore C11-C17 `static_assert` fallback (GH-160705) (