https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101494
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-07-21 Status|UNCONFIRMED |NEW CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed. I think this exposes two underlying bugs: one that the initialization isn't detected and another that the second argument to attribute access isn't respected. A slightly enhanced test case: $ cat b.c && gcc -O2 -S -Wall b.c __attribute__ ((access (read_only, 1, 2))) void f (const void*, int); void g (void) { char *p = __builtin_alloca (1); *p = 0; f (p, 0); // bogus -Wmaybe-uninitialized } void h (void) { char *p = __builtin_malloc (1); f (p, 0); // bogus -Wmaybe-uninitialized } b.c: In function ‘g’: b.c:7:3: warning: ‘p’ is used uninitialized [-Wuninitialized] 7 | f (p, 0); // bogus -Wmaybe-uninitialized | ^~~~~~~~ b.c:1:49: note: in a call to ‘f’ declared with attribute ‘access (read_only, 1, 2)’ here 1 | __attribute__ ((access (read_only, 1, 2))) void f (const void*, int); | ^ b.c: In function ‘h’: b.c:13:3: warning: ‘p’ is used uninitialized [-Wuninitialized] 13 | f (p, 0); // bogus -Wmaybe-uninitialized | ^~~~~~~~ b.c:1:49: note: in a call to ‘f’ declared with attribute ‘access (read_only, 1, 2)’ here 1 | __attribute__ ((access (read_only, 1, 2))) void f (const void*, int); | ^