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

            Bug ID: 124229
           Summary: [reflection] using type alias defined with splice
                    expression of annotation as template arg T to
                    extract<T> causes ICE
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: giel+gcc at mortis dot eu
  Target Milestone: ---

Created attachment 63779
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63779&action=edit
example code where extract(annotation) ICEs

When experimenting with annotations on enumerators I encountered an internal
compiler error when trying to extract(annotation).

I've attached the reduced code and also added it on compiler explorer:
https://godbolt.org/z/6fa8bv99j

If I omit the type alias in that code and use `extract<typename
[:type_of(annotation):]>(annotation)` it compiles and works as expected (see
#else variant in code).

Locally I tested this with a build of the 20260215 snapshot for GCC 16.

Compiler Explorer appears to use a trunk build from 20260224.

The backtrace produced:

<source>: In instantiation of 'template for' iteration 1:
<source>:34:34:   required from here
   34 |     template for (constexpr auto val :
define_static_array(enumerators_of(^^error)))
      |                                  ^~~
<source>:49:55: internal compiler error: in cxx_incomplete_type_diagnostic, at
cp/typeck2.cc:518
   49 |             constexpr auto message = extract<msg_type>(annotation);
      |                                      ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
0x2962da8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2957aeb internal_error(char const*, ...)
        ???:0
0xb219b0 fancy_abort(char const*, int, char const*)
        ???:0
0xe4c4d7 complete_type_or_maybe_complain(tree_node*, tree_node*, int)
        ???:0
0xe4c59c require_complete_type(tree_node*, int)
        ???:0
0xb3e496 build_cxx_call(tree_node*, int, tree_node**, int, tree_node*)
        ???:0
0xb5a457 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xe0a155 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xdcc0a6 finish_expansion_stmt(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd6cfc3 c_parse_file()
        ???:0
0xef6d69 c_common_parse_file()
        ???:0
/cefs/e8/e82fee45f682ac519c43e178_gcc-trunk-20260224/bin/../libexec/gcc/x86_64-linux-gnu/16.0.1/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/e8/e82fee45f682ac519c43e178_gcc-trunk-20260224/bin/../lib/gcc/x86_64-linux-gnu/16.0.1/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -O3 -Wall -Wextra -Werror
-Wno-deprecated -Wno-unused-parameter -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

Reply via email to