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

            Bug ID: 122055
           Summary: -Wanalyzer-use-of-uninitialized-value false positive
                    with self initialization and no optimizations
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

On the following code

int f(void)
{
  int i = i;
  i = 1;
  return i;
}

with GCC 16.0.0 20250921 [master r16-4006-g749af111496] in Debian:

qaa:~> gcc-snapshot -c tst.c -fanalyzer
tst.c: In function 'f':
tst.c:3:7: warning: use of uninitialized value 'i' [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    3 |   int i = i;
      |       ^
  'f': events 1-3
    3 |   int i = i;
      |       ^
      |       |
      |       (1) region created on stack here
      |       (2) capacity: 4 bytes
      |       (3) ⚠️  use of uninitialized value 'i' here

This warning disappears with -O (or higher optimization).

Reproducible with earlier GCC versions.
  • [Bug analyzer/122055] New: -Wan... vincent-gcc at vinc17 dot net via Gcc-bugs

Reply via email to