http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46853
--- Comment #3 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com>
2010-12-09 14:36:15 UTC ---
There are already many bug reports about missing "used uninitialized" warnings
(such as my PR42905). It seems that the GCC devs do not take them all to heart.
> 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.
In fact, GCC optimises func into
int func(void)
{
return 0xFF;
}
Undefined behavior, so it's correct.