https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82101
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED CC| |msebor at gcc dot gnu.org Component|c++ |middle-end --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 11 in C++ mode warns at all optimization levels: $ cat pr82101.c && gcc -Wall -xc++ pr82101.c int main(){ int k=k; for(int i = 0 ; i < 10 ; i ++){ int t=t; } return 0; } pr82101.c: In function ‘int main()’: pr82101.c:2:9: warning: ‘k’ is used uninitialized [-Wuninitialized] 2 | int k=k; | ^ pr82101.c:2:9: note: ‘k’ was declared here 2 | int k=k; | ^ According to my bisection, in C++ mode it started warning with r138835 (4.4.0 20080712), so I'm puzzled by Version being set to 7.1.1. In C it never warned. I think C still doesn't complain about self-initialization to accommodate the hack as a suppression mechanism for -Wuninitialized/-Wmaybe-uinitialized. So with that, I'm going to resolve this as fixed.