[Bug c/46853] gcc fails to warn about uninitialized variable
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?
[Bug c/46853] gcc fails to warn about uninitialized variable
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.
[Bug c/46853] gcc fails to warn about uninitialized variable
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46853 --- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org 2010-12-09 14:40:12 UTC --- (In reply to comment #3) It seems that the GCC devs do not take them all to heart. No, they just don't have the resources to fix them all. It's not an easy problem.
[Bug c/46853] gcc fails to warn about uninitialized variable
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46853 Manuel López-Ibáñez manu at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED CC||manu at gcc dot gnu.org Resolution||DUPLICATE --- Comment #5 from Manuel López-Ibáñez manu at gcc dot gnu.org 2010-12-09 14:45:18 UTC --- (In reply to comment #3) 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. Fixing those bugs would require major work. There is no enough people to do that work. And those bugs are not considered important by core devs. You may have more luck with clang-analyzer, but I think it is still quite green for C++ bugs. In fact, GCC optimises func into int func(void) { return 0xFF; } Undefined behavior, so it's correct. Almost 99% sure this is PR 18501. However your PR42905 seems a novel case to me, no idea why it was closed. *** This bug has been marked as a duplicate of bug 18501 ***
[Bug c/46853] gcc fails to warn about uninitialized variable
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46853 --- Comment #1 from Richard Guenther rguenth at gcc dot gnu.org 2010-12-08 20:35:19 UTC --- This is a dup of x, we apply conditional constant and copy propagation which will optimize the uninitialized use away before we have a chance to warn.