This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/39870] New: VRP can't see through cast to unsigned
- From: "aph at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Apr 2009 15:44:07 -0000
- Subject: [Bug tree-optimization/39870] New: VRP can't see through cast to unsigned
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A common way to do array bounds checking is to cast the index i to unsigned and
then check
if ((unsigned)i > (unsigned)length)
abort();
instead of
if (i >= length || i < 0)
abort();
The phrases are equivalent, but VRP doesn't know that so the bounds check is
not eliminated.
The problem is that this is such a common idiom that it will affect many
programs.
--
Summary: VRP can't see through cast to unsigned
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aph at gcc dot gnu dot org
GCC host triplet: x86_64-linux-gnu
OtherBugsDependingO 21855
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39870