https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67915
Bug ID: 67915 Summary: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following code causes an ICE when compiled with the current gcc trunk at -O2 and -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. It is a regression from 5.2.x. $ 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-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 6.0.0 20151009 (experimental) [trunk revision 228653] (GCC) $ $ gcc-trunk -Os -c small.c $ gcc-5.2 -O2 -c small.c $ $ gcc-trunk -O2 -c small.c small.c: In function ‘fn2’: small.c:10:1: internal compiler error: Segmentation fault fn2 () ^ 0xaaee4f crash_signal ../../gcc-trunk/gcc/toplev.c:353 0x81c4c4 tree_unary_nonnegative_warnv_p(tree_code, tree_node*, tree_node*, bool*, int) ../../gcc-trunk/gcc/fold-const.c:12822 0x82f0ef fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) ../../gcc-trunk/gcc/fold-const.c:11257 0xaf5067 cleanup_control_expr_graph ../../gcc-trunk/gcc/tree-cfgcleanup.c:116 0xaf5067 cleanup_control_flow_bb ../../gcc-trunk/gcc/tree-cfgcleanup.c:211 0xaf5067 cleanup_tree_cfg_bb ../../gcc-trunk/gcc/tree-cfgcleanup.c:628 0xaf56a8 cleanup_tree_cfg_1 ../../gcc-trunk/gcc/tree-cfgcleanup.c:681 0xaf56a8 cleanup_tree_cfg_noloop ../../gcc-trunk/gcc/tree-cfgcleanup.c:733 0xaf56a8 cleanup_tree_cfg() ../../gcc-trunk/gcc/tree-cfgcleanup.c:788 0x9e9384 execute_function_todo ../../gcc-trunk/gcc/passes.c:1915 0x9e9c83 execute_todo ../../gcc-trunk/gcc/passes.c:2028 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. $ ----------------------------------- int a, b, c, d, e, f, g; int fn1 (int p1) { return p1; } void fn2 () { lbl: g = b; if (fn1 (c && e)) { f = a ? 0 : 1 << 1; short h = b; d = h < 0 || f ? 0 : 1; } goto lbl; }