https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122092
Bug ID: 122092
Summary: ICE: tree check: did not expect class ‘type’, have
‘type’ (record_type) in contains_placeholder_p, at
tree.cc:4085
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: qingren2hxb at gmail dot com
Target Milestone: ---
Created attachment 62466
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62466&action=edit
bug report by using -freport-bug
Input:
#include <iostream>
struct Base {
unsigned int *intarray;
};
template <typename T>
struct Sub : public Base {
bool Get(int i) {
return (Base::intarray[++i] == 0);
}
};
int main() {
Sub<int> s;
s.intarray = new unsigned int[10];
s.Get(0);
delete[] s.intarray;
return 0;
}
Output:
test.cpp:11:31: internal compiler error: tree check: did not expect class
‘type’, have ‘type’ (record_type) in contains_placeholder_p, at tree.cc:4085
11 | return (Base::intarray[++i] == 0);
| ^
0x29adc7d tree_not_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
/workspace/gcc/gcc/tree.cc:8980
0xd2175f non_type_check(tree_node*, char const*, int, char const*)
/workspace/gcc/gcc/tree.h:3719
0x298a71d contains_placeholder_p(tree_node const*)
/workspace/gcc/gcc/tree.cc:4085
0x298b13a contains_placeholder_p(tree_node const*)
/workspace/gcc/gcc/tree.cc:4120
0x2989be7 save_expr(tree_node*)
/workspace/gcc/gcc/tree.cc:3948
0x142d27c cp_build_array_ref(unsigned int, tree_node*, tree_node*, int)
/workspace/gcc/gcc/cp/typeck.cc:4066
0x142d6b6 build_array_ref(unsigned int, tree_node*, tree_node*)
/workspace/gcc/gcc/cp/typeck.cc:4106
0xf32963 grok_array_decl(unsigned int, tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, int)
/workspace/gcc/gcc/cp/decl2.cc:582
0x114c894 cp_parser_postfix_open_square_expression
/workspace/gcc/gcc/cp/parser.cc:8223
0x114a396 cp_parser_postfix_expression
/workspace/gcc/gcc/cp/parser.cc:7814
0x11507e6 cp_parser_unary_expression
/workspace/gcc/gcc/cp/parser.cc:9138
0x1152f75 cp_parser_cast_expression
/workspace/gcc/gcc/cp/parser.cc:10044
0x11530f5 cp_parser_binary_expression
/workspace/gcc/gcc/cp/parser.cc:10147
0x1154e07 cp_parser_assignment_expression
/workspace/gcc/gcc/cp/parser.cc:10491
0x115555a cp_parser_expression
/workspace/gcc/gcc/cp/parser.cc:10661
0x1141190 cp_parser_primary_expression
/workspace/gcc/gcc/cp/parser.cc:5768
0x114a0a2 cp_parser_postfix_expression
/workspace/gcc/gcc/cp/parser.cc:7777
0x11507e6 cp_parser_unary_expression
/workspace/gcc/gcc/cp/parser.cc:9138
0x1152f75 cp_parser_cast_expression
/workspace/gcc/gcc/cp/parser.cc:10044
0x11530f5 cp_parser_binary_expression
/workspace/gcc/gcc/cp/parser.cc:10147
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.