You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement request: make pycore_cell.h compile cleanly under C++ #144490
This isn’t a “real issue” report, since pycore_cell.h (and the helpers it declares) are internal implementation details, so I understand they’re not part of the stable/public API, not guaranteed to be C++-compatible, and may change or disappear in future CPython versions. I’m still asking about this because the fix is very small.
While adapting CinderX to FT-Python, we include pycore_cell.h from a C++ (in the JIT/codegen path for LOAD_DEREF / STORE_DEREF). This currently fails to compile under C++ unless -fpermissive is used.
pycore_cell.h already has extern "C" guards, so it looks intended to be usable from C++ in at least some capacity. Would it be acceptable to add an explicit cast so it compiles cleanly under C++?``
<source>:8:12: error: cannot initialize return object of type 'Foo *' with an rvalue of type 'void *'
8 | return malloc(sizeof(Foo));
| ^~~~~~~~~~~~~~~~~~~
I modified test_cext (C) and test_cppext (C++) to test the internal C API on 3.14 and main branches. test_cppext now includes the pycore_cell.h header file.
Currently, test_cppext skips pycore_backoff.h and pycore_cell.h since they include mimalloc which emits C++ compiler warnings.
Activity
vstinner commentedon Feb 5, 2026
What is the error message? What is your compiler (name/version)?
colesbury commentedon Feb 5, 2026
I think most compilers error or warn for this pattern in C++: https://gcc.godbolt.org/z/dvsoqvPzd
Typically with something like:
GCC:
Clang:
yoney commentedon Feb 5, 2026
clang version 19.1.2, it should be similar for other compilers, C++ is stricter on implicit conversions.
pythongh-144490: Fix test_cppext: test the internal C API
gh-144490: Fix test_cppext: test the internal C API (#144536)
pythongh-144490: Test the internal C API in test_cppext
gh-144490: Fix C++ compatibility in pycore_cell.h (GH-144482)
pythongh-144490: Fix C++ compatibility in pycore_cell.h (pythonGH-144482
[3.14] gh-144490: Fix C++ compatibility in pycore_cell.h (GH-144482) (G…
pythongh-144490: Fix mimalloc debug build
pythongh-144490: Fix test_cppext on Windows
pythongh-144490: Fix test_cppext on Windows (python#144628)
pythongh-144490: Fix test_cppext on Windows (python#144628)
[3.14] gh-144490: Test the internal C API in test_cppext (#144547)
gh-144490: Fix mimalloc debug build for C++ (#144620)
pythongh-144490: Test the internal C API in test_cext
[3.14] gh-144490: Test the internal C API in test_cext (#144678)
vstinner commentedon Feb 10, 2026
I modified test_cext (C) and test_cppext (C++) to test the internal C API on 3.14 and main branches. test_cppext now includes the
pycore_cell.hheader file.Currently, test_cppext skips
pycore_backoff.handpycore_cell.hsince they include mimalloc which emits C++ compiler warnings.pythongh-144490: Fix test_cppext: test the internal C API (python#144536
pythongh-144490: Fix C++ compatibility in pycore_cell.h (pythonGH-144482
pythongh-144490: Fix test_cppext on Windows (python#144628)
pythongh-144490: Fix mimalloc debug build for C++ (python#144620)
pythongh-144490: Fix mimalloc debug build for C++ (python#144620)
pythongh-144490: Fix test_cppext: test the internal C API (python#144536
pythongh-144490: Fix C++ compatibility in pycore_cell.h (pythonGH-144482
pythongh-144490: Fix test_cppext on Windows (python#144628)
pythongh-144490: Fix mimalloc debug build for C++ (python#144620)