https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85285
Bug ID: 85285
Summary: [6/7/8 Regression] ICE with flexible array in union
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: reichelt at gcc dot gnu.org
Target Milestone: ---
The following invalid code snippet triggers an ICE since GCC 6.1.0:
=================================
template<typename T> struct A
{
union
{
T x;
};
};
A<int[]> a;
=================================
bug.cc: In instantiation of 'union A<int []>::<unnamed>':
bug.cc:3:3: required from 'struct A<int []>'
bug.cc:9:10: required from here
bug.cc:4:3: internal compiler error: Segmentation fault
{
^
0xebdf8f crash_signal
../../gcc/gcc/toplev.c:325
0xbf84cb contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
../../gcc/gcc/tree.h:3248
0xbf84cb size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*)
../../gcc/gcc/fold-const.c:1883
0xeb2937 place_union_field
../../gcc/gcc/stor-layout.c:1193
0xeb2937 place_field(record_layout_info_s*, tree_node*)
../../gcc/gcc/stor-layout.c:1253
0x839a22 layout_nonempty_base_or_field
../../gcc/gcc/cp/class.c:4048
0x8454f4 layout_class_type
../../gcc/gcc/cp/class.c:6109
0x84a7ea finish_struct_1(tree_node*)
../../gcc/gcc/cp/class.c:6804
0x9928ab instantiate_class_template_1
../../gcc/gcc/cp/pt.c:11060
0x9928ab instantiate_class_template(tree_node*)
../../gcc/gcc/cp/pt.c:11100
0x9d8f7d complete_type(tree_node*)
../../gcc/gcc/cp/typeck.c:136
0x99275f instantiate_class_template_1
../../gcc/gcc/cp/pt.c:10896
0x99275f instantiate_class_template(tree_node*)
../../gcc/gcc/cp/pt.c:11100
0x9d8f7d complete_type(tree_node*)
../../gcc/gcc/cp/typeck.c:136
0x885fc7 start_decl_1(tree_node*, bool)
../../gcc/gcc/cp/decl.c:5275
0x8ac267 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../gcc/gcc/cp/decl.c:5238
0x93d573 cp_parser_init_declarator
../../gcc/gcc/cp/parser.c:19610
0x944d48 cp_parser_simple_declaration
../../gcc/gcc/cp/parser.c:13049
0x945b58 cp_parser_block_declaration
../../gcc/gcc/cp/parser.c:12874
0x949ae2 cp_parser_declaration
../../gcc/gcc/cp/parser.c:12772
Please submit a full bug report, [etc.]