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

            Bug ID: 126093
           Summary: [17 regression] (reflection) ICE in
                    write_unqualified_name, at cp/mangle.cc:1570
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mkryss at dawn dot wine
  Target Milestone: ---

Trunk g++ (tested on 75a75f22f) ICEs on the following code
(https://godbolt.org/z/qE9doK1To):
#include <meta>

struct S {
    template<typename T>
    operator T() {}
};

int main() {
    constexpr auto members = define_static_array(std::meta::members_of(^^S,
                        std::meta::access_context::unchecked()));
}


With output:
$ g++ -std=c++26 -freflection test.cpp
In file included from test.cpp:1:
include/c++/17.0.0/meta: In function 'int main()':
test.cpp:10:49:   in 'constexpr' expansion of
'std::define_static_array<vector<std::meta::info> >(std::meta::members_of(^^S,
ctx))'
   10 |     constexpr auto members =
define_static_array(std::meta::members_of(^^S, ctx));
      |                             
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/c++/17.0.0/meta:648:50: internal compiler error: tree check: expected
function_decl, have template_decl in write_unqualified_name, at
cp/mangle.cc:1570
  648 |       auto __array = meta::reflect_constant_array(__r);
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
0x295896c internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:787
0xa1c422 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.cc:9216
0x83f465 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3810
0x83f465 write_unqualified_name
        ../../gcc/gcc/cp/mangle.cc:1570
0xc79484 write_reflection
        ../../gcc/gcc/cp/mangle.cc:4281
0xc79484 write_template_arg_literal
        ../../gcc/gcc/cp/mangle.cc:4442
0xc7b767 write_expression
        ../../gcc/gcc/cp/mangle.cc:3962
0xc83e69 mangle_template_parm_object(tree_node*)
        ../../gcc/gcc/cp/mangle.cc:5376
0xdea2a2 eval_reflect_constant_array
        ../../gcc/gcc/cp/reflect.cc:6473
0xdf25d0 process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
        ../../gcc/gcc/cp/reflect.cc:8260
0xb82ce5 cxx_eval_call_expression
        ../../gcc/gcc/cp/constexpr.cc:4062
0xb85ea0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ../../gcc/gcc/cp/constexpr.cc:9428
0xb8c895 cxx_eval_store_expression
        ../../gcc/gcc/cp/constexpr.cc:7872
0xb85c28 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ../../gcc/gcc/cp/constexpr.cc:9609
0xb85da8 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ../../gcc/gcc/cp/constexpr.cc:10150

$ ./g++ -v
Using built-in specs.
COLLECT_GCC=./g++
COLLECT_LTO_WRAPPER=/home/mkryss/dev/random-stuff/gcc-stuff/gcc-build/install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --disable-nls --enable-languages=c,c++
--disable-multilib --disable-bootstrap --disable-libsanitizer --disable-libgomp
--disable-libitm --disable-libatomic --disable-libquadmath --disable-libssp
--disable-libvtv --disable-libcc1 CFLAGS='-O2 -ggdb3' CXXFLAGS='-O2 -ggdb3'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260703 (experimental) (GCC)

It seems to not happen in gcc 16.1, so it's most likely a regression since
then.

Reply via email to