https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128941
Bug ID: 128941
Summary: [c++26 reflection] gcc trunk (but not gcc 16) yields
internal compiler error: in mark_needed, at
cp/decl2.cc:2829
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: songb432 at gmail dot com
Target Milestone: ---
Link: https://godbolt.org/z/1fTaPr8dq
```
struct Ok
{
static constexpr int foo() { return 3; }
static const int value;
};
constexpr int Ok::value = Ok::foo();
struct ICE_on_GCC_trunk
{
static consteval decltype(^^::) foo()
{ return ^^int; }
static const decltype(^^::) value;
// error in GCC 16: error: consteval-only variable
// 'ICE_on_GCC_trunk::value' not declared 'constexpr'
// used outside a constant-evaluated context.
// compiler note: add 'constexpr'
};
constexpr decltype(^^::) ICE_on_GCC_trunk::value
= ICE_on_GCC_trunk::foo(); // ok in clang (reflection).
```
GCC trunk output:
internal compiler error: in mark_needed, at cp/decl2.cc:2829
22 | = ICE_on_GCC_trunk::foo(); // ok in clang (reflection).
| ^
0x2d38ce8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2d2d92b internal_error(char const*, ...)
???:0
0xc249a0 fancy_abort(char const*, int, char const*)
???:0
0xd3b228 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
???:0
0xe81783 c_parse_file()
???:0
0x1018359 c_common_parse_file()
???:0
/cefs/0e/0e5a6d6a44296fe6afec0600_gcc-trunk-20261121/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/0e/0e5a6d6a44296fe6afec0600_gcc-trunk-20261121/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++26
-fdiagnostics-color=always -fno-verbose-asm -freflection -o /app/output.s
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.
Compiler returned: 1