Skip to content

BUG: Avoid compile errors in f2py modules #29043

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

Merged
merged 1 commit into from
May 23, 2025

Conversation

charris
Copy link
Member

@charris charris commented May 23, 2025

I've hit a couple of compile errors when using f2py -c ...:

../module.c:341:53: error: passing argument 1 of ‘PyArray_TYPE’ from incompatible pointer type [-Wincompatible-pointer-types]
  341 |         else if (PyArray_Check(obj) && PyArray_TYPE(obj) == NPY_LONGDOUBLE) {
      |                                                     ^~~
      |                                                     |
      |                                                     PyObject * {aka struct _object *}
In file included from /usr/lib64/python3.13/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12,
                 from /usr/lib64/python3.13/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
                 from /usr/lib64/python3.13/site-packages/numpy/f2py/src/fortranobject.h:16,
                 from ../flibmodule.c:23:
/usr/lib64/python3.13/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1567:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1567 | PyArray_TYPE(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~

../module.c:342:53: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
  342 |             (*v) = *((npy_longdouble *)PyArray_DATA(obj));
      |                                                     ^~~
      |                                                     |
      |                                                     PyObject * {aka struct _object *}
/usr/lib64/python3.13/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1512:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1512 | PyArray_DATA(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~

Following some of the other uses of this API in the cfuncs file, this just uses an explicit pointer cast, as we've already validated it upon use.

Some of the casts from cfuncs pass PyObject* to PyArrayObject*, which
causes compile errors due to incompatible pointer types on at least
GCC 14.
@charris charris added this to the 2.3.0 release milestone May 23, 2025
@charris charris merged commit 819c089 into numpy:maintenance/2.3.x May 23, 2025
73 checks passed
@charris charris deleted the backport-29034 branch May 23, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
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