https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70396
Bug ID: 70396 Summary: ICE on valid code at -O3 in 32-bit and 64-bit modes on x86_64-linux-gnu (in immed_wide_int_const, at emit-rtl.c:606) Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- The following code crashes the trunk at -O3 in 32-bit and 64-bit modes on x86_64-linux-gnu. $: gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 6.0.0 20160324 (experimental) [trunk revision 234448] (GCC) $: $: gcc-trunk -O3 small.c small.c:4:5: warning: array ‘a’ assumed to have one element int a[]; ^ small.c: In function ‘fn1’: small.c:11:14: warning: iteration 2147483645 invokes undefined behavior [-Waggressive-loop-optimizations] for (; c; c++) { ~^~ small.c:11:3: note: within this loop for (; c; c++) { ^~~ small.c:7:6: internal compiler error: in immed_wide_int_const, at emit-rtl.c:606 void fn1() { ^~~ 0x806f7d immed_wide_int_const(generic_wide_int<wide_int_ref_storage<false> > const&, machine_mode) ../../gcc-source-trunk/gcc/emit-rtl.c:606 0x82b5ce const_vector_from_tree ../../gcc-source-trunk/gcc/expr.c:11531 0x82b5ce expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc-source-trunk/gcc/expr.c:9748 0xa65c6a expand_expr ../../gcc-source-trunk/gcc/expr.h:256 0xa65c6a vector_compare_rtx ../../gcc-source-trunk/gcc/optabs.c:5299 0xa7025d expand_vec_cond_expr(tree_node*, tree_node*, tree_node*, tree_node*, rtx_def*) ../../gcc-source-trunk/gcc/optabs.c:5629 0x840c35 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc-source-trunk/gcc/expr.c:9358 0x7274a1 expand_gimple_stmt_1 ../../gcc-source-trunk/gcc/cfgexpand.c:3654 0x7274a1 expand_gimple_stmt ../../gcc-source-trunk/gcc/cfgexpand.c:3714 0x7296ea expand_gimple_basic_block ../../gcc-source-trunk/gcc/cfgexpand.c:5720 0x72eafe execute ../../gcc-source-trunk/gcc/cfgexpand.c:6335 Please submit a full bug report, with preprocessed source if appropriate. gcc version 6.0.0 20160324 (experimental) [trunk revision 234448] (GCC) $: $: gcc-trunk -O3 small.c small.c:4:5: warning: array ‘a’ assumed to have one element int a[]; ^ small.c: In function ‘fn1’: small.c:11:14: warning: iteration 2147483645 invokes undefined behavior [-Waggressive-loop-optimizations] for (; c; c++) { ~^~ small.c:11:3: note: within this loop for (; c; c++) { ^~~ small.c:7:6: internal compiler error: in immed_wide_int_const, at emit-rtl.c:606 void fn1() { ^~~ 0x806f7d immed_wide_int_const(generic_wide_int<wide_int_ref_storage<false> > const&, machine_mode) ../../gcc-source-trunk/gcc/emit-rtl.c:606 0x82b5ce const_vector_from_tree ../../gcc-source-trunk/gcc/expr.c:11531 0x82b5ce expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc-source-trunk/gcc/expr.c:9748 0xa65c6a expand_expr ../../gcc-source-trunk/gcc/expr.h:256 0xa65c6a vector_compare_rtx ../../gcc-source-trunk/gcc/optabs.c:5299 0xa7025d expand_vec_cond_expr(tree_node*, tree_node*, tree_node*, tree_node*, rtx_def*) ../../gcc-source-trunk/gcc/optabs.c:5629 0x840c35 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc-source-trunk/gcc/expr.c:9358 0x7274a1 expand_gimple_stmt_1 ../../gcc-source-trunk/gcc/cfgexpand.c:3654 0x7274a1 expand_gimple_stmt ../../gcc-source-trunk/gcc/cfgexpand.c:3714 0x7296ea expand_gimple_basic_block ../../gcc-source-trunk/gcc/cfgexpand.c:5720 0x72eafe execute ../../gcc-source-trunk/gcc/cfgexpand.c:6335 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 small.c struct S2 { signed f1 : 3; }; int a[]; int b, c; char d; void fn1() { struct S2 e; b / e.f1; c = 2; for (; c; c++) { d = 0; a[c] = ~e.f1 != d; } } $: