https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69253
Bug ID: 69253 Summary: g++ ICE (segfault) at -O0 on x86_64-linux-gnu in "cxx_incomplete_type_diagnostic" Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: helloqirun at gmail dot com Target Milestone: --- The following code causes an ICE when compiled with the current g++ trunk at -O0 on x86_64-linux-gnu in both 32-bit and 64-bit modes. Please note that g++ with -O1 and above compiles the code snippet. Should g++ allow the initialization of flexible array members? $ 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/6.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 6.0.0 20160112 (experimental) [trunk revision 232269] (GCC) $ g++-trunk -O0 -c abc.cc abc.cc: In function 'void fn1()': abc.cc:5:33: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:567 void fn1() { (struct str){1, ""}; } ^ 0x6c53cf cxx_incomplete_type_diagnostic(tree_node const*, tree_node const*, diagnostic_t) ../../gcc/gcc/cp/typeck2.c:567 0xf863fa size_in_bytes(tree_node const*) ../../gcc/gcc/tree.c:2925 0xa1369c int_expr_size ../../gcc/gcc/expr.c:11639 0xa2709a store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) ../../gcc/gcc/expr.c:5360 0xa28821 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/gcc/expr.c:5021 0x91a9be expand_gimple_stmt_1 ../../gcc/gcc/cfgexpand.c:3606 0x91a9be expand_gimple_stmt ../../gcc/gcc/cfgexpand.c:3702 0x91e0a4 expand_gimple_basic_block ../../gcc/gcc/cfgexpand.c:5708 0x923076 execute ../../gcc/gcc/cfgexpand.c:6323 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. ------------------ $ cat abc.cc struct str { int a; char s[]; }; void fn1() { (struct str){1, ""}; }