https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119004

            Bug ID: 119004
           Summary: Inconsistent set of flags to trigger -Wstrict-overflow
                    diagnostics
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alx at kernel dot org
  Target Milestone: ---

-Wstrict-overflow somehow is not enough to trigger its own diagnostics.  I seem
to need -Wall too.  :|


alx@debian:~/tmp$ cat foo.c 
#include <limits.h>
int
dont_call_me_thrice(void)
{
        static int i = 0;

        if (++i >= 3)
                return -1;

        return 0;
}
alx@debian:~/tmp$ gcc -Wstrict-overflow -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=0 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=1 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=2 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=3 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=4 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow=5 -S foo.c 
alx@debian:~/tmp$ gcc -Wstrict-overflow -Wstrict-overflow=5 -S foo.c 
alx@debian:~/tmp$ gcc -Wall -Wstrict-overflow=5 -S foo.c 
foo.c: In function ‘dont_call_me_thrice’:
foo.c:11:1: warning: assuming signed overflow does not occur when changing X +-
C1 cmp C2 to X cmp C2 -+ C1 [-Wstrict-overflow]
   11 | }
      | ^
alx@debian:~/tmp$ gcc -Wall -S foo.c
alx@debian:~/tmp$ 


(Don't mind that this is a false positive of -Wstrict-overflow; I'll report
that separately.)

Reply via email to