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

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
At -O0 the warning looks right although not as nice as what the analyzer prints
(but the analyzer doesn't catch it at -O1 or higher):

$ gcc -S -Wall -fanalyzer z.c
z.c: In function ‘f’:
z.c:5:7: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
    5 |     z = x;
      |     ~~^~~
z.c:3:7: note: ‘x’ was declared here
    3 |   int x, y = j, z;
      |       ^
z.c:5:7: warning: use of uninitialized value ‘x’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    5 |     z = x;
      |     ~~^~~
  ‘f’: events 1-3
    |
    |    4 |   if (i)
    |      |      ^
    |      |      |
    |      |      (1) following ‘true’ branch (when ‘i != 0’)...
    |    5 |     z = x;
    |      |     ~~~~~
    |      |       |
    |      |       (2) ...to here
    |      |       (3) use of uninitialized value ‘x’ here
    |

Reply via email to