https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98901
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Resolution|--- |DUPLICATE Status|NEW |RESOLVED --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- With the -Wdangling-pointer patch (see bug 63272 comment 5) GCC diagnoses the problem in both the test case in attachment 50096: test2.c: In function ‘main’: test2.c:34:5: warning: using dangling pointer ‘p’ to ‘x’ [-Wdangling-pointer=] test2.c:29:13: note: ‘x’ declared here test2.c:33:5: warning: using dangling pointer ‘p’ to ‘x’ [-Wdangling-pointer=] test2.c:29:13: note: ‘x’ declared here and the one in comment #1: $ gcc -O2 -S -Wall pr98901.c pr98901.c: In function ‘main’: pr98901.c:13:9: warning: using dangling pointer ‘p’ to ‘x’ [-Wdangling-pointer=] 13 | return *p; | ^~ pr98901.c:7:9: note: ‘x’ declared here 7 | int x = 0; | ^ pr98901.c:11:3: warning: using dangling pointer ‘p’ to ‘x’ [-Wdangling-pointer=] 11 | f (1, p); // missing warning | ^~~~~~~~ pr98901.c:7:9: note: ‘x’ declared here 7 | int x = 0; | ^ *** This bug has been marked as a duplicate of bug 63272 ***