http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46853
--- Comment #2 from gcc-bugs at nospam dot pz.podzone.net 2010-12-09 08:36:46 UTC --- The variable can be optimised away in the WHILE_LOOP test case so in effect the variable 'foo' is never used uninitialised. However with the FOR_LOOP test case it is not possible to optimise away the variable 'foo' and it is unclear what value the function will eventually return. In theory the for loop and the variable 'i' could be optimised away, but I doubt gcc actually does this. However imagine that gcc did so then the FOR_LOOP test case should generate the same warning as the basic test case, but it does not. Is it unreasonable to expect gcc to warn about uninitialised use of the variable in such cases where it is not optimised away?