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

            Bug ID: 123475
           Summary: wrong warning about variable used uninitialized
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rootkit85 at yahoo dot it
  Target Milestone: ---

This code snippet:

```
void cap_last_cap(void) {
        _Atomic int saved = 1000;
        int c;

        c = saved;
}
```

Gives the following warning:

undef.c: In function ‘cap_last_cap’:
undef.c:5:11: warning: ‘D.4590’ is used uninitialized [-Wuninitialized]
    5 |         c = saved;
      |         ~~^~~~~~~
undef.c:5:9: note: ‘D.4590’ was declared here
    5 |         c = saved;
      |         ^

To reproduce it I use this command line:
gcc -Wall -ftrivial-auto-var-init=zero -O2 -o /dev/null -c undef.c

Some system information:

$ cat /etc/fedora-release
Fedora release 44 (Rawhide)

$ rpm -q gcc
gcc-16.0.0-0.4.fc44.aarch64

Reply via email to