Skip to content

Build failures against NumPy 2.0 with GCC 14 #393

@mgorny

Description

@mgorny

When using a stricter compiler (e.g. GCC 14) and building against NumPy 2.0.0rc2, the build fails over a bunch of type mismatches:

building 'fitsio._fitsio_wrap' extension
creating build/temp.linux-x86_64-cpython-312/fitsio
gcc-14 -fno-strict-overflow -Wsign-compare -fPIC -I/usr/lib/python3.12/site-packages/numpy/_core/include -Ibuild/temp.linux-x86_64-cpython-312/cfitsio-4.2.0 -Ibuild/temp.linux-x86_64-cpython-312/cfitsio-4.2.0 -I/usr/include/python3.12 -c fitsio/fitsio_pywrap.c -o build/temp.linux-x86_64-cpython-312/fitsio/fitsio_pywrap.o
In file included from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1909,
                 from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12,
                 from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
                 from fitsio/fitsio_pywrap.c:28:
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
fitsio/fitsio_pywrap.c: In function ‘get_int64_from_array’:
fitsio/fitsio_pywrap.c:561:29: error: passing argument 1 of ‘PyArray_TYPE’ from incompatible pointer type [-Wincompatible-pointer-types]
  561 |     npy_type = PyArray_TYPE(arr);
      |                             ^~~
      |                             |
      |                             PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1563:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1563 | PyArray_TYPE(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1021:50: error: passing argument 1 of ‘PyArray_CHKFLAGS’ from incompatible pointer type [-Wincompatible-pointer-types]
 1021 | #define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
      |                                                  ^~~
      |                                                  |
      |                                                  PyObject * {aka struct _object *}
fitsio/fitsio_pywrap.c:575:10: note: in expansion of macro ‘PyArray_ISCONTIGUOUS’
  575 |     if (!PyArray_ISCONTIGUOUS(arr)) {
      |          ^~~~~~~~~~~~~~~~~~~~
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1569:39: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1569 | PyArray_CHKFLAGS(const PyArrayObject *arr, int flags)
      |                  ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:580:28: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
  580 |     colnums = PyArray_DATA(arr);
      |                            ^~~
      |                            |
      |                            PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1508 | PyArray_DATA(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:581:27: error: passing argument 1 of ‘PyArray_DIMS’ from incompatible pointer type [-Wincompatible-pointer-types]
  581 |     *ncols = PyArray_SIZE(arr);
      |                           ^~~
      |                           |
      |                           PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:79:59: note: in definition of macro ‘PyArray_SIZE’
   79 | #define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))
      |                                                           ^
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1520:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1520 | PyArray_DIMS(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:581:27: error: passing argument 1 of ‘PyArray_NDIM’ from incompatible pointer type [-Wincompatible-pointer-types]
  581 |     *ncols = PyArray_SIZE(arr);
      |                           ^~~
      |                           |
      |                           PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:79:76: note: in definition of macro ‘PyArray_SIZE’
   79 | #define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))
      |                                                                            ^
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1502:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
 1502 | PyArray_NDIM(const PyArrayObject *arr)
      |              ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c: In function ‘PyFITSObject_create_image_hdu’:
fitsio/fitsio_pywrap.c:1451:34: error: passing argument 1 of ‘PyArray_TYPE’ from incompatible pointer type [-Wincompatible-pointer-types]
 1451 |         npy_dtype = PyArray_TYPE(array);
      |                                  ^~~~~
      |                                  |
      |                                  PyObject * {aka struct _object *}
[…]

(the list is actually quite long)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions