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

             Bug #: 56928
           Summary: false positive when using -Wstrict-overflow
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: vap...@gentoo.org
            Target: x86_64-linux-gnu


i've got some code that is triggering a warning when using gcc-4.8.0 and -O2
with -Wstrict-overflow.  pretty sure the warning is wrong -- when i tweak the
code slightly (in unrelated ways), it goes away.

playing with older versions shows that 4.[234].x work, but 4.[5678].x fail

the reduced test case:
$ cat test.i
struct stat {
    int st_mode;
};
const char *foo(char c, int x, struct stat s)
{   
    int i;
    char dynamic = 0;
    if (c == 1)
        for (i = 0; i < x; i++)
            dynamic = 1;
    if (!dynamic || !(s.st_mode & 1))
        return dynamic ? "d" : "!d";
}

$ gcc -O2 -c test.i -Wstrict-overflow 
test.i: In function ‘foo’:
test.i:12:24: warning: assuming signed overflow does not occur when simplifying
conditional to constant [-Wstrict-overflow]
   return dynamic ? "d" : "!d";
                        ^

Reply via email to