https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66772
            Bug ID: 66772
           Summary: ICE 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.1.x. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-unknown-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 20150705 (experimental) [trunk revision 225420] (GCC) 
$ 
$ gcc-trunk -Os small.c; ./a.out
$ gcc-5.1 -O2 small.c; ./a.out
$ 
$ gcc-trunk -O2 small.c
small.c: In function ‘fn4’:
small.c:44:1: internal compiler error: Segmentation fault
 }
 ^
0xbaf42f crash_signal
        ../../gcc-trunk/gcc/toplev.c:360
0x83dc3b contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc-trunk/gcc/tree.h:2971
0x83dc3b fold_comparison
        ../../gcc-trunk/gcc/fold-const.c:8593
0x81dce5 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
        ../../gcc-trunk/gcc/fold-const.c:11895
0xbf6f24 cleanup_control_expr_graph
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:128
0xbf6f24 cleanup_control_flow_bb
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:223
0xbf6f24 cleanup_tree_cfg_bb
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:640
0xbf7548 cleanup_tree_cfg_1
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:693
0xbf7548 cleanup_tree_cfg_noloop
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:745
0xbf7548 cleanup_tree_cfg()
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:800
0xaeb8e4 execute_function_todo
        ../../gcc-trunk/gcc/passes.c:1910
0xaec183 execute_todo
        ../../gcc-trunk/gcc/passes.c:2014
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, e, f;

void fn1 (int p) { }

int
fn2 (int p)
{
  return a ? p % a : 0; 
}

short
fn3 (int p)
{
  return (1 >> p) < 1 ? 1 : p;
}

int
fn4 ()
{
  int g = 0, h = 1;
  if (b)
    goto lbl;
  fn2 (0);
  if (fn3 (1))
    fn1 (e && c);
  if (h)
    {
      int i = 1;
    lbl:
      if (i)
        return 0;
      for (; g < 1; g++)
        ;
    }
  for (;;)
    f || g > 0;
}

int
main ()
{
  fn4 (); 
  return 0;
}

Reply via email to