[Bug middle-end/66031] Spurious array bounds warning

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 6 10:41:00 GMT 2015


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-05-06
                 CC|                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We are confused by f being unsigned char somehow, so we don't see
that

  <bb 3>:
  i_7 = i_1 + 1;
  _8 = (unsigned int) i_7;
  _9 = _8 + 4294967295;
  _10 = (unsigned int) f.1_5;
  if (_9 >= _10)
    goto <bb 4>;
  else
    goto <bb 6>;

  <bb 4>:
  _11 = p[_8];
  _12 = (char) _11;
...

is never executed (thus _9 >= _10 is true).

DOM doesn't figure that out either, we are missing the simplification of

  i_7 = i_1 + 1;
  _8 = (unsigned int) i_7;
  _9 = _8 + 4294967295;

to

  _9 = (unsigned int) i_1;

but then we still have an unsigned int compare against f in one path and
a signed int one in the other.  We'd have to canonicalize to one form to
eventually make DOM recognize the redundant compare - which OTOH won't help
VRP to omit the warning (because VRP runs before DOM).  VRPs analysis is
not able to optimize such redundancy because it doesn't track symbolic
ranges in addition to regular ones here.

Summary: hard problem.



More information about the Gcc-bugs mailing list