[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 10:09:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60165
--- Comment #5 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Jakub Jelinek from comment #3)
> The code path exists in the code,
It exists *only* if fn2() can return 0. But the fact is that in the reality,
this can never happen (with the original non-reduced code, this can even be
proved).
> the fact that perhaps in your program such
> code path is never taken doesn't mean it is undesirable to warn about it.
> GCC has two kinds of warnings, the is uninitialized one where particular
> code, if executed, will always use uninitialized value, and maybe
> uninitialized, where it will use uninitialized value only conditionally.
> That is the case here.
But in this case, the warning is missing with -O2.
> No, usually with more inlining it increases and should. When fn1 is not
> inlined, GCC intentionally does not warn that c might be uninitialized
> because maybe the function call could use the value or not set it
> unconditionally, that would lead to so huge amount of false positives for
> the warning that nobody would be willing to use the warning.
This is the same problem with -O3: there is a false positive here. So, you have
to choose whether you want to avoid false positives or not.
More information about the Gcc-bugs
mailing list