https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125630

            Bug ID: 125630
           Summary: ICE in nothrow_spec_p with nanobind overload_cast on
                    CGAL::Point_3::operator=
           Product: gcc
           Version: 13.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: utkarshkhajuria55 at gmail dot com
  Target Milestone: ---

I am reporting an internal compiler error encountered while building the CGAL
Python bindings with GCC 13.3.0 on Ubuntu 24.04.

Exact GCC version:

gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1)

System type:

x86_64-linux-gnu

GCC configure/build options:

../src/configure -v --with-pkgversion='Ubuntu 13.3.0-6ubuntu2~24.04.1'
--with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-13
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-13-EldibY/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-EldibY/gcc-13-13.3.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2

Thread model:

posix

Compiler output / ICE:

In file included from
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include/cgalpy/Kernel/export_kernel.hpp:34,
                 from
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/lib/export_approximate_kernel.cpp:16:
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include/cgalpy/Kernel/export_point_3.hpp:
In substitution of ‘template<class Return, class Class> constexpr decltype
(pmf) nanobind::detail::overload_cast_impl<const
CGAL::Point_3<CGAL::Cartesian<double> >&>::operator()(Return (Class::*)(const
CGAL::Point_3<CGAL::Cartesian<double> >&), std::false_type) const [with Return
= <missing>; Class = <missing>]’:
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include/cgalpy/Kernel/export_point_3.hpp:42:49:
  required from ‘void export_point_3(C&) [with Kernel_ =
CGAL::Cartesian<double>; C =
nanobind::class_<CGAL::Point_3<CGAL::Cartesian<double> > >]’
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include/cgalpy/Kernel/export_kernel.hpp:384:24:
  required from ‘void export_kernel(C_&) [with Kernel_ =
CGAL::Cartesian<double>; C_ = nanobind::class_<CGAL::Cartesian<double> >]’
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/lib/export_approximate_kernel.cpp:25:23:
  required from here
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include/cgalpy/Kernel/export_point_3.hpp:42:49:
internal compiler error: in nothrow_spec_p, at cp/except.cc:1196
   42 |     .def("assign", py::overload_cast<const Pnt&>(&Pnt::operator=))
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

Failing source location:

src/libs/cgalpy/include/cgalpy/Kernel/export_point_3.hpp:42

Failing statement:

.def("assign", py::overload_cast<const Pnt&>(&Pnt::operator=))

Translation unit:

src/libs/cgalpy/lib/export_approximate_kernel.cpp

Complete command line:

The attached file `gcc-ice-export_approximate_kernel-report.out` contains the
full cc1plus command line emitted by GCC, along with the compiler diagnostic
and preprocessed source.

The command line begins with:

/usr/libexec/gcc/x86_64-linux-gnu/13/cc1plus -quiet -I
/home/runner/work/cgal-python-bindings/cgal-python-bindings/build/cgalpy/epec/src/libs/cgalpy/include/generated
-I
/home/runner/work/cgal-python-bindings/cgal-python-bindings/src/libs/cgalpy/include
-I /opt/hostedtoolcache/Python/3.12.13/x64/include/python3.12 -I
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/nanobind/include
...

Preprocessed source / reproduction attachment:

I am attaching `gcc-ice-export_approximate_kernel-report.out` directly rather
than an archive. It is the GCC-generated report file containing the diagnostic,
full command line, and preprocessed source content.

Project context:

This was found while building the CGAL Python bindings in GitHub Actions.

Project:
TAU-CGL/cgal-python-bindings

Temporary repro branch:
gcc-ice-report

Temporary repro commit:
c4bad58e Generate GCC ICE report artifact

Old failing source commit:
14ae1fd0 Add GitHub Actions EPEC smoke workflow

Fixed source commit:
465cf9e7 Fix point assign binding for GCC

GitHub Actions repro run:
https://github.com/TAU-CGL/cgal-python-bindings/actions/runs/26909280938

GitHub Actions job:
79382624660

Workaround used in the project:

The issue was worked around in the project by replacing the nanobind
`py::overload_cast` usage for `Point_3::operator=` with an explicit
`static_cast`, and by adding the corresponding `Point_2` assign binding.

Expected behavior:

GCC should either compile the translation unit successfully or emit a normal
diagnostic if the source is invalid.

Actual behavior:

GCC crashes with an internal compiler error in `nothrow_spec_p`, at
`cp/except.cc:1196`.

Reply via email to