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

--- Comment #1 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Here's the corresponding simple testcase:

typedef struct { int *a; } S;
int *f (void);
static void g (S *x)
{
  int *p = x->a;
  p[0] = 0;
}
void h (void)
{
  S x[1];
  x->a = f ();
  g (x);
}

$ gcc-10 -c -fanalyzer bug.i
bug.i: In function ‘g’:
bug.i:6:8: warning: use of uninitialized value ‘p’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    6 |   p[0] = 0;
      |   ~~~~~^~~
  ‘h’: events 1-2
    |
    |    8 | void h (void)
    |      |      ^
    |      |      |
    |      |      (1) entry to ‘h’
    |......
    |   12 |   g (x);
    |      |   ~~~~~
    |      |   |
    |      |   (2) calling ‘g’ from ‘h’
    |
    +--> ‘g’: events 3-4
           |
           |    3 | static void g (S *x)
           |      |             ^
           |      |             |
           |      |             (3) entry to ‘g’
           |......
           |    6 |   p[0] = 0;
           |      |   ~~~~~~~~   
           |      |        |
           |      |        (4) use of uninitialized value ‘p’ here
           |

Reply via email to