http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53198

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-03
          Component|c                           |tree-optimization
            Summary|[4.6 Regression] gcc        |[4.6/4.7 Regression] gcc
                   |wrongly emits "array        |wrongly emits "array
                   |subscript is above array    |subscript is above array
                   |bounds" for simple arrays   |bounds" for simple arrays
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-05-03 
10:46:30 UTC ---
Confirmed.  This is because of loop header copying doing

<bb 2>:
  D.1711_8 = devices[0];
  if (D.1711_8 != 0B)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 3>:
  i_7 = 0;

<bb 4>:
  # i_9 = PHI <0(3), i_4(4)>
  i_4 = i_9 + 1;
  D.1711_3 = devices[i_4];
  if (D.1711_3 != 0B)
    goto <bb 4>;
  else
    goto <bb 5>;

thus VRP sees that the access in the loop uses indices of [1, INF] which
is out-of bounds.  In 4.8 we recognize that the loop can only run once
(because of the initializer size) and optimize the variable array access
away.

Reply via email to