[Bug tree-optimization/60165] "may be used uninitialized" warning with -O3 but not with -O2
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Thu Feb 13 13:48:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60165
--- Comment #15 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Manuel López-Ibáñez from comment #10)
> Now, I agree that ideally, GCC should warn for your last testcase. But I
> guess in that case inlining either doesn't happen or it happens too late, so
> GCC only sees the first case. The analysis that GCC performs are predicated
> on the transformations leading to better code, otherwise they are not
> performed. A tool for static analysis will surely inline as much as it
> could, not matter if the code is slower or larger, but this is not how GCC
> works because GCC is not a tool for static analysis.
Well, detecting uninitialized variables is equivalent to generating better
code. See the following functions. If you want to be able to remove the i == 0
test in the first one (making generated code better), you'll solve the warning
problem in the second one.
int f(void)
{
int i = 0;
/* some code that sets i to a nonzero value, but difficult to prove */
if (i == 0)
abort();
return i;
}
int f(void)
{
int i;
/* some code that sets i to a nonzero value, but difficult to prove */
return i;
}
More information about the Gcc-bugs
mailing list