Testcase :

#include <sys/types.h>
#include <stdio.h>

void foo(ssize_t x)
{
 if (x >= 0) {
   if (x+x < 0) printf("Overflow\n");
}
}

main()
{
  volatile ssize_t x =2147483647;
  foo(x);
}

When compiled with -O2 it doesn't print Overflow, if you omit -O2 it prints
overflow.
gcc 3.4.6 works fine so this is a regression.


-- 
           Summary: [4.3 regression] Overflow check is optimized away when -
                    O2 is enabled
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ismail at pardus dot org dot tr


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

Reply via email to