https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87398
Bug ID: 87398 Summary: g++ ICE on valid code: tree check: expected record_type or union_type or qual_union_type, have array_type in cxx_eval_constant_expression, at cp/constexpr.c:4820 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: helloqirun at gmail dot com Target Milestone: --- It happens with flag "-std=c++2a". It appears to start with r264408. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 9.0.0 20180923 (experimental) [trunk revision 264513] (GCC) $ g++-trunk -std=c++2a abc.C abc.C: In function ‘void c()’: abc.C:7:20: internal compiler error: tree check: expected record_type or union_type or qual_union_type, have array_type in cxx_eval_constant_expression, at cp/constexpr.c:4820 7 | int d(e[4][d].b()); | ^ 0x79a6c4 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/gcc/tree.c:9369 0x880c98 tree_check3(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code) ../../gcc/gcc/tree.h:3153 0x880c98 cxx_eval_constant_expression ../../gcc/gcc/cp/constexpr.c:4820 0x87bdd7 cxx_eval_call_expression ../../gcc/gcc/cp/constexpr.c:1508 0x87df1d cxx_eval_constant_expression ../../gcc/gcc/cp/constexpr.c:4284 0x8832fe cxx_eval_outermost_constant_expr ../../gcc/gcc/cp/constexpr.c:5018 0x886518 maybe_constant_value(tree_node*, tree_node*) ../../gcc/gcc/cp/constexpr.c:5245 0x8963d1 cp_fully_fold(tree_node*) ../../gcc/gcc/cp/cp-gimplify.c:2120 0x89e28f cp_convert_and_check(tree_node*, tree_node*, int) ../../gcc/gcc/cp/cvt.c:656 0x84c3b5 convert_like_real ../../gcc/gcc/cp/call.c:7219 0x84d508 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int) ../../gcc/gcc/cp/call.c:10938 0xa15311 digest_init_r ../../gcc/gcc/cp/typeck2.c:1195 0xa17f02 digest_init_flags(tree_node*, tree_node*, int, int) ../../gcc/gcc/cp/typeck2.c:1211 0xa17f02 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ../../gcc/gcc/cp/typeck2.c:808 0x8ae4ed check_initializer ../../gcc/gcc/cp/decl.c:6481 0x8c657f cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ../../gcc/gcc/cp/decl.c:7152 0x961466 cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:19893 0x968653 cp_parser_simple_declaration ../../gcc/gcc/cp/parser.c:13189 0x96a1b9 cp_parser_declaration_statement ../../gcc/gcc/cp/parser.c:12608 0x949023 cp_parser_statement ../../gcc/gcc/cp/parser.c:10953 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. $ cat abc.C class a { public: virtual long b(); }; void c() { a e[5][2]; int d(e[4][d].b()); }