https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109550
Bug ID: 109550 Summary: warning: "p" may be used uninitialized Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenb...@fh-soft.de Target Milestone: --- % cat test.c #include <stdlib.h> int f (char const *p); void a (void) { char const *p = alloca (1); f (p); } % gcc -c -Wall test.c test.c: In function "a": test.c:8:3: warning: "p" may be used uninitialized [-Wmaybe-uninitialized] 8 | f (p); | ^~~~~ test.c:3:5: note: by argument 1 of type "const char *" to "f" declared here 3 | int f (char const *p); | ^ It also happens with "malloc" instead of "alloca", but not with a normal function. The warning disappears when removing "const" in both places. Ironically, when trying to work around the warning, I noticed that wrapping alloca in another function gets rid of the warning. However, that would actually be wrong (dangling pointer).