https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126204
Bug ID: 126204
Summary: internal compiler error: in
cxx_eval_constant_expression, at cp/constexpr.cc:10607
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lukaslang.bugtracker at outlook dot com
Target Milestone: ---
The following code causes an internal compiler error in GCC 14.1 and later
versions (Godbolt link: https://godbolt.org/z/c4jTfqGzv):
#include <algorithm>
auto foo()
{
[](auto)
{
(true ? std::copy<int*, int*> : std::copy<int*, int*>)(
nullptr,nullptr,nullptr
);
};
}
<source>: In lambda function:
<source>:7:22: internal compiler error: in cxx_eval_constant_expression, at
cp/constexpr.cc:10607
7 | (true ? std::copy<int*, int*> : std::copy<int*, int*>)(
| ~~~~~^~~~~~~~~~~~~~~~
/cefs/78/786049f38ac2e951480666f4_arm_gcc-trunk-20260710/arm-unknown-linux-gnueabihf/bin/../libexec/gcc/arm-unknown-linux-gnueabihf/17.0.0/cc1plus
-quiet -iprefix
/cefs/78/786049f38ac2e951480666f4_arm_gcc-trunk-20260710/arm-unknown-linux-gnueabihf/bin/../lib/gcc/arm-unknown-linux-gnueabihf/17.0.0/
-isysroot
/cefs/78/786049f38ac2e951480666f4_arm_gcc-trunk-20260710/arm-unknown-linux-gnueabihf/bin/../arm-unknown-linux-gnueabihf/sysroot
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -mfloat-abi=hard -mfpu=neon -mtls-dialect=gnu -mthumb
-mlibarch=armv7-a+simd -march=armv7-a+simd -g -fdiagnostics-color=always
-fno-verbose-asm -o /app/output.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
Every piece seems required for this bug to trigger:
- The lambda function
- The lambda function parameter
- The ternary (casting to a function pointer instead produces a different ICE)
- The call of the function pointer