https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89217
Bug ID: 89217
Summary: ICE tree check: expected constructor, have error_mark
in split_nonconstant_init_1
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mawww at kakoune dot org
Target Milestone: ---
Created attachment 45613
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45613&action=edit
Source file that triggers the bug.
Compiling the following source (attached as well):
struct R {};
struct C
{
R* begin() const { return &r; }
R* end() const { return &r; }
R& r;
};
struct S
{
void f1() { f2<true>(); }
template<bool>
void f2()
{
for (auto i : C{r}) {}
}
R& r;
};
Leads to an internal compiler error:
test.cc: In instantiation of ‘void S::f2() [with bool <anonymous> = true]’:
test.cc:13:26: required from here
test.cc:18:9: error: cannot convert ‘((S*)this)->S::r’ from type ‘R’ to type
‘R*’
18 | for (auto i : C{r}) {}
| ^~~
test.cc:18:9: internal compiler error: tree check: expected constructor, have
error_mark in split_nonconstant_init_1, at cp/typeck2.c:635
0x7bb804 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../.././gcc/tree.c:9813
0x671510 tree_check(tree_node*, char const*, int, char const*, tree_code)
../.././gcc/tree.h:3176
0x671510 split_nonconstant_init_1
../.././gcc/cp/typeck2.c:635
0xa5fced split_nonconstant_init(tree_node*, tree_node*)
../.././gcc/cp/typeck2.c:760
0x896f15 set_up_extended_ref_temp
../.././gcc/cp/call.c:11297
0x896f15 extend_ref_init_temps_1
../.././gcc/cp/call.c:11434
0xa628a7 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
../.././gcc/cp/typeck2.c:833
0x8f07c2 check_initializer
../.././gcc/cp/decl.c:6508
0x91079c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../.././gcc/cp/decl.c:7184
0x9804b1 cp_convert_range_for(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int, bool, unsigned short)
../.././gcc/cp/parser.c:12361
0x9cf457 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17116
0x9cc449 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:17212
0x9cbdce tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../.././gcc/cp/pt.c:16896
0x9cbdce instantiate_decl(tree_node*, bool, bool)
../.././gcc/cp/pt.c:24584
0xa01f3b instantiate_pending_templates(int)
../.././gcc/cp/pt.c:24700
0x9200f0 c_parse_final_cleanups()
../.././gcc/cp/decl2.c:4792