Consider this C test case:

const char *
f(long v)
{
  if (v < 0)
    v = - v;
  if (v > 0x7fffffff)
    return "negative";
  else
    return "positive";
}

When this is compiled with -O2, it always returns "positive".  This is fine
because when v == LONG_MIN, negating it is undefined signed overflow.  However,
the same is true when this is compiled with -O2 -fno-strict-overflow, which is
not fine.  With -fno-strict-overflow, we can not assume that negating a signed
value yields a nonnegative number.

This bug is neither serious nor a regression, so I'm recording it here in order
to fix it for gcc 4.4.


-- 
           Summary: -fno-strict-overflow fails to prevent use of signed
                    overflow
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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

Reply via email to