-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyArray_Descr API is not compatible with the Python Limited API #16970
Comments
A simple reproducer is https://godbolt.org/z/dc8vaz This seems to pass in GCC 10, and in all versions of clang. So I'd argue this is a GCC bug. |
Is this a bug in GCC? Or is this a nonstandard GCC/Clang extension? |
I'm honestly not sure. In my opinion, dereferencing an opaque struct only to take it's address again should be legal, no memory access actually occurs. |
Here are the related GCC bug reports, which were indeed fixed in GCC 10:
The bug reports refer to 6.5.3.2/3 of ISO/IEC 9899:2018, which describes a special rule for evaluation of the & operator when the operand is the result of the * operator. So yes, this is standards-conforming C, and it was a bug in GCC to reject it, fixed in GCC 10 and later. I was able to work around this in my project by adding a blank forward declaration of PyTypeObject (see lpsinger/ligo.skymap@b1bc1ab). |
According to numpy/numpy#16970 (comment), no versions of clang exhibit this bug. However, clang defines __GNUC__, which we use to detect misbehaving versions of gcc. We now additionally detect whether __clang__ is defined, which should differentiate gcc from clang.
According to numpy/numpy#16970 (comment), no versions of clang exhibit this bug. However, clang defines __GNUC__, which we use to detect misbehaving versions of gcc. We now additionally detect whether __clang__ is defined, which should differentiate gcc from clang.
According to numpy/numpy#16970 (comment), no versions of clang exhibit this bug. However, clang defines __GNUC__, which we use to detect misbehaving versions of gcc. We now additionally detect whether __clang__ is defined, which should differentiate gcc from clang.
Functions to create a new array using a
PyArray_Descr *
do not support the PEP 384 Python Limited API.Reproducing code example:
foo.c
setup.py
Error message:
Failed output with limited Python API
Successful output with full Python API
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: