https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65178
--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Leon Winter from comment #9) > > If you declare it outside the loop body, gcc generates exactly the same code > > for a 'for' and a 'do-while'. > > You are right. When I did the testing, I mistakenly left out "-O1" or such > so I did not see the warning :/ > Probably there is no way to hint to the compiler a code path is always > visited (similar to "likely()"/"unlikely()") so we will stick with gcc-4.9.x > for the time being. If you initialize buff that would silence the warning. If GCC is not able to remove the initialization at -O2, -O3, -Os, that would be a missed optimization worth reporting as a new PR. There are more devs working on optimizations than on diagnostics (I guess the former is more important to paying customers than the latter). Sometimes it just takes fixing the missed optimization to fix the warning, but other times it takes more work. Are you saying that GCC 4.9 does not warn? That would be surprising and a regression. If you could find the revision that started warning, that would be helpful.