https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78964
--- Comment #2 from David Binderman <dcb314 at hotmail dot com> --- >Why should it warn? For all the same reasons as warning -Wunused-but-set-variable. See the following code: extern void g( int); void f( int n) { int m = 0; int m2 = 2; for (int i = 0; i < n; ++i) { g(i); ++m; } m2 = 3; } $ ~/gcc/results/bin/gcc -c -O2 -Wall jan02.cc jan02.cc: In function ‘void f(int)’: jan02.cc:7:6: warning: variable ‘m2’ set but not used [-Wunused-but-set-variable] int m2 = 2; ^~ $ The compiler warns about m2, but not m. Anomaly.