This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/39870] New: VRP can't see through cast to unsigned


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]