KEMBAR78
Compilation failure with GCC 15 + Python 3.12: `mypyc/lib-rt/pythoncapi_compat.h:41:11: error: ‘_Py_NULL’ redefined [-Werror]` · Issue #18698 · python/mypy · GitHub
Skip to content

Compilation failure with GCC 15 + Python 3.12: mypyc/lib-rt/pythoncapi_compat.h:41:11: error: ‘_Py_NULL’ redefined [-Werror] #18698

@mr-c

Description

@mr-c

Bug Report

Hello, in Debian we are testing the upcoming GCC 15 release, and we found a compilation error when compiling for Python 3.12.

The Debian bug report is at https://bugs.debian.org/1097426

To Reproduce

Compile using GCC 15.x

To build with GCC 15, either set CC=gcc-15 CXX=g++-15 explicitly, or install the gcc, g++, gfortran, ... packages from Debian experimental.

apt-get -t=experimental install g++

GCC 15 now defaults to the C23/C++23 standards, exposing many FTBFS. Other Common build failures are new warnings resulting in build failures with -Werror turned on, or new/dropped symbols in Debian symbols files. For other C/C++ related build failures see the porting guide at http://gcc.gnu.org/gcc-15/porting_to.html

Expected Behavior

Compilation suceeds

Actual Behavior

x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/mypy-1.15.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wno-misleading-indentation -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.12 -c build/mypy/checkmember.c -o build/temp.linux-x86_64-cpython-312/build/mypy/checkmember.o -O3 -g2 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
In file included from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/pythonsupport.h:11,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/CPy.h:12,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/init.c:2,
                 from build/__native_3204bda914b7f2c6f497.c:1:
/build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/pythoncapi_compat.h:41:11: error: ‘_Py_NULL’ redefined [-Werror]
   41 | #  define _Py_NULL nullptr
      |           ^~~~~~~~
In file included from /usr/include/python3.12/Python.h:38,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/init.c:1:
/usr/include/python3.12/pyport.h:32:11: note: this is the location of the previous definition
   32 | #  define _Py_NULL NULL
      |           ^~~~~~~~

Your Environment

  • GCC version: 15-20250213-1
  • Mypy version used: 1.15.0
  • Mypy command-line flags: NA
  • Python version used: 3.12.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions