https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
Bug ID: 102539
Summary: [11/12 regression] -Wmaybe-uninitialized false
positive, invalid <unknown> location
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: slyfox at gcc dot gnu.org
Target Milestone: ---
Minimal example is extracted from aerospike-server-4.2.0.4:
$ cat a.c.c
void msg_set_buf(const int *);
void clustering_hb_event_listener_buffer_size(void) {
unsigned long succession_buffer = (unsigned long)__builtin_alloca(42);
msg_set_buf((const int*)succession_buffer);
}
$ LANG=C /nix/store/...-gcc-wrapper-12.0.0/bin/gcc -fno-strict-aliasing -Wall
-std=gnu99 -o a.o -c a.c.c -O2
a.c.c: In function 'clustering_hb_event_listener_buffer_size':
a.c.c:4:3: warning: '<unknown>' may be used uninitialized
[-Wmaybe-uninitialized]
4 | msg_set_buf((const int*)succession_buffer);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.c.c:1:6: note: by argument 1 of type 'const int *' to 'msg_set_buf' declared
here
1 | void msg_set_buf(const int *);
| ^~~~~~~~~~~
There are two issues here (both are probably related):
1. '<unknown>' location is reported instead of some form of 'succession_buffer'
reference
2. there should be no warning about uninitialized data, it's the same pointer
passed around
$ LANG=C /nix/store/...-gcc-wrapper-12.0.0/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/nix/store/...-gcc-12.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/nix/store/...-gcc-12.0.0/libexec/gcc/x86_64-unknown-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210919 (experimental) (GCC)
Affected compilers:
- 12.0.0 20210919 snapshot
- 11.1.0 release
Unaffected compilers:
- 10.3.0 release