https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115952
Bug ID: 115952 Summary: g++ 14.1.0 internal compiler error for ambiguous function template overloads Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aslobodkins at mail dot smu.edu Target Milestone: --- ***************************************************************************** I am using g++ 14.1.0 on Ubunutu 22.04 and encountered internal compiler error when working on one of my recent projects. The function call is ambiguous and compiler should issue a corresponding error message. Instead, the output is as follows: ***************************************************************************** slobod@LinuxHPC:~/Documents/Research/strict-lib/example$ make example2 g++-14.1 -std=c++20 -DSTRICT_DEBUG_OFF example2.cpp -o example2.x -lm -I ../src/ example2.cpp: In function ‘int main()’: example2.cpp:11:29: internal compiler error: Segmentation fault 11 | Z(place::all, place::all)(0, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ 0x742a4804251f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x742a48029d8f __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x742a48029e3f __libc_start_main_impl ../csu/libc-start.c:392 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. make: *** [Makefile:32: example2] Error 1 ***************************************************************************** Other compilers, such as 18.1.3 or g++ 13.2.0 report the error properly as follows: ***************************************************************************** clang++ -std=c++20 -DSTRICT_DEBUG_OFF example2.cpp -o example2.x -lm -I ../src/ example2.cpp:11:4: error: call to object of type 'Derived2D<ConstSliceArrayBase2D<ThisType>>' (aka 'Derived2D<ConstSliceArrayBase2D<Derived2D<slib::ArrayBase2D<double>>>>') is ambiguous 11 | Z(place::all, place::all)(0, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~ ../src/derived2D.hpp:70:53: note: candidate function [with I1 = int, I2 = int] 70 | STRICT_NODISCARD_CONSTEXPR_INLINE decltype(auto) operator()(I1 i, I2 j); | ^ ../src/derived2D.hpp:247:36: note: candidate function [with S1 = int, S2 = int] 247 | STRICT_NODISCARD_CONSTEXPR auto operator()(S1 s1, S2 s2) && | ^ 1 error generated. make: *** [Makefile:32: example2] Error 1 ***************************************************************************** slobod@LinuxHPC:~/Documents/Research/strict-lib/example$ make example2 g++-13.2 -std=c++20 -DSTRICT_DEBUG_OFF example2.cpp -o example2.x -lm -I ../src/ example2.cpp: In function ‘int main()’: example2.cpp:11:29: error: call of ‘(slib::Derived2D<slib::ConstSliceArrayBase2D<slib::Derived2D<slib::ArrayBase2D<double> > > >) (int, int)’ is ambiguous 11 | Z(place::all, place::all)(0, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from ../src/array_IO.hpp:13, from ../src/strict_lib.hpp:10, from example2.cpp:2: ../src/derived2D.hpp:357:50: note: candidate: ‘constexpr decltype(auto) slib::Derived2D<Base>::operator()(I1, I2) [with I1 = int; I2 = int; Base = slib::ConstSliceArrayBase2D<slib::Derived2D<slib::ArrayBase2D<double> > >]’ 357 | STRICT_NODISCARD_CONSTEXPR_INLINE decltype(auto) Derived2D<Base>::operator()(I1 i, I2 j) { | ^~~~~~~~~~~~~~~ ../src/derived2D.hpp:366:50: note: candidate: ‘constexpr decltype(auto) slib::Derived2D<Base>::operator()(I1, I2) const [with I1 = int; I2 = int; Base = slib::ConstSliceArrayBase2D<slib::Derived2D<slib::ArrayBase2D<double> > >]’ 366 | STRICT_NODISCARD_CONSTEXPR_INLINE decltype(auto) Derived2D<Base>::operator()(I1 i, I2 j) const { | ^~~~~~~~~~~~~~~ ../src/derived2D.hpp:830:33: note: candidate: ‘constexpr auto slib::Derived2D<Base>::operator()(S1, S2) const & [with S1 = int; S2 = int; Base = slib::ConstSliceArrayBase2D<slib::Derived2D<slib::ArrayBase2D<double> > >]’ 830 | STRICT_NODISCARD_CONSTEXPR auto Derived2D<Base>::operator()(S1 s1, S2 s2) const& { | ^~~~~~~~~~~~~~~ ../src/derived2D.hpp:863:33: note: candidate: ‘constexpr auto slib::Derived2D<Base>::operator()(S1, S2) && requires !(ArrayTwoDimType<slib::Derived2D<Base> >) [with S1 = int; S2 = int; Base = slib::ConstSliceArrayBase2D<slib::Derived2D<slib::ArrayBase2D<double> > >]’ 863 | STRICT_NODISCARD_CONSTEXPR auto Derived2D<Base>::operator()(S1 s1, S2 s2) && | ^~~~~~~~~~~~~~~ make: *** [Makefile:32: example2] Error 1 ***************************************************************************** I have attached preprocessed file by adding save-temps option to Makefile. Compiler configuration settings were: ../gcc-releases-gcc-14.1.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-14.1