https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70771

            Bug ID: 70771
           Summary: ICE on valid code at -O3 on x86_64-linux-gnu in
                    operator[], at vec.h:714
           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
-O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes.

It is a regression from 5.3.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/7.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 --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160423 (experimental) [trunk revision 235384] (GCC)
$
$ gcc-trunk -O2 small.c; ./a.out
$ gcc-5.3 -O3 small.c; ./a.out
$
$ gcc-trunk -O3 small.c
small.c: In function ‘main’:
small.c:18:1: internal compiler error: in operator[], at vec.h:714
 main ()
 ^~~~
0xba5e89 vec<edge_def*, va_gc, vl_embed>::operator[](unsigned int)
        ../../gcc-source-trunk/gcc/vec.h:714
0xba5e89 gimple_phi_arg_edge
        ../../gcc-source-trunk/gcc/gimple.h:4339
0xba5e89 replace_uses_by(tree_node*, tree_node*)
        ../../gcc-source-trunk/gcc/tree-cfg.c:1818
0xba60b1 gimple_merge_blocks
        ../../gcc-source-trunk/gcc/tree-cfg.c:1938
0x74cf75 merge_blocks(basic_block_def*, basic_block_def*)
        ../../gcc-source-trunk/gcc/cfghooks.c:787
0xbaecc4 cleanup_tree_cfg_bb
        ../../gcc-source-trunk/gcc/tree-cfgcleanup.c:660
0xbaf598 cleanup_tree_cfg_1
        ../../gcc-source-trunk/gcc/tree-cfgcleanup.c:710
0xbaf598 cleanup_tree_cfg_noloop
        ../../gcc-source-trunk/gcc/tree-cfgcleanup.c:761
0xbaf598 cleanup_tree_cfg()
        ../../gcc-source-trunk/gcc/tree-cfgcleanup.c:812
0xa9ad74 execute_function_todo
        ../../gcc-source-trunk/gcc/passes.c:1921
0xa9b7cb execute_todo
        ../../gcc-source-trunk/gcc/passes.c:2020
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;

static void
fn1 ()
{ 
  for (b = 0; b < 1; b++)
      for (c = 0; c < 1; c++)
        { 
          if (a)
            break;
          b = 1;
        }
  for (;;)
    ;
}

int
main ()
{ 
  if (d)
    fn1 ();
  return 0;
}

Reply via email to