This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36296] wrong warning about potential uninitialized variable
- From: "vincent at vinc17 dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 May 2008 11:23:15 -0000
- Subject: [Bug middle-end/36296] wrong warning about potential uninitialized variable
- References: <bug-36296-16207@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from vincent at vinc17 dot org 2008-05-22 11:23 -------
BTW, the i = i trick, which is guaranteed to be valid and no-op only *after* i
has been initialized doesn't avoid the warning in such a case. I don't know if
this would be a good feature (the main drawback I can see would be to miss
warnings when this is a result of macro expansion). For instance:
#include <assert.h>
int foo (int x)
{
int y;
assert (x == 0 || x == 1);
if (x == 0)
y = 1;
else if (x == 1)
y = 2;
y = y; /* to tell the compiler that y has been initialized */
return y;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296