[Bug tree-optimization/58736] New: IVOPTs rewrites unsigned to signed arith, exposing undefined overflow

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 15 11:06:00 GMT 2013


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

            Bug ID: 58736
           Summary: IVOPTs rewrites unsigned to signed arith, exposing
                    undefined overflow
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
            Target: x86_64-*-*

Split out from PR58143,

/* { dg-do run } */
/* { dg-additional-options "-fstrict-overflow" } */

int a, b, c, d, e;

int
main ()
{
  for (b = 4; b > -30; b--)
    {
      e = a > (int)((unsigned int) __INT_MAX__ - (unsigned int) b);
      for (; c;)
        for (;;)
          {
            if (d)
              break;
          }
    }
  return 0;
}

is compiled to an infinite loop at -O3 by IVOPTs and VRP teaming up,
rewriting (unsigned int) __INT_MAX__ - (unsigned int) b as signed arithmetic
and then removing the loop exit test.



More information about the Gcc-bugs mailing list