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

            Bug ID: 115089
           Summary: -Wanalyzer-use-of-uninitialized-value false negative
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: alx at kernel dot org
  Target Milestone: ---

For this code, which I wrote to try to trigger
-Wanalyzer-use-of-uninitialized-value:

$ cat bug.c 
#include <stdlib.h>

void
g(int *x)
{
        if (arc4random() % 2)
                *x = 42;
}

int
main(void)
{
        int x;

        g(&x);
        return x;  // maybe uninitialized use
}


I'm having a hard time triggering the warning.  No combination of flags seems
to trigger it.

$ gcc -Wall -Wextra -O3 -flto -fsanitize=undefined -fanalyzer bug.c
$ ./a.out; echo $?
42
$ ./a.out; echo $?
0

I tried 0,1,2,3 optimization levels, and nothing.  Also tried both
    gcc (Debian 13.2.0-24) 13.2.0
and
    gcc-14 (Debian 14-20240429-1) 14.0.1 20240429 (experimental) [gcc-14
r14-10144-g41d7a8ceaaa]

Reply via email to