https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98900
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 12 issues -Wdangling-poinnter for this bug now at all optimization levels. It still issues -Wuninitialized at -O1 and above, but with the dangling pointer warning I don't think it's a big deal. It should of course still be possible to suppress it. $ cat pr98900.c && gcc -S -Wall pr98900.c int g = 10; int main() { int* p = 0; { int x = 15; p = &x; } g = *p; return 0; } pr98900.c: In function ‘main’: pr98900.c:11:9: warning: using dangling pointer ‘p’ to ‘x’ [-Wdangling-pointer=] 11 | g = *p; | ^~ pr98900.c:7:13: note: ‘x’ declared here 7 | int x = 15; | ^