named warnings & individual warning control

Joe Buck Joe.Buck@synopsys.COM
Sat Jun 26 00:49:00 GMT 2004


On Fri, Jun 25, 2004 at 04:02:19PM -0700, Stan Shebs wrote:
> So if I understand what you're getting at, it would be to have some
> weaker form of flow analysis in the front end to implement the
> uninitialized warnings, even if that means reporting some false
> positives? I can go for that; if it takes a complicated analysis to
> determine that a variable really is initialized before use, there's a
> good chance that the code is only working correctly by accident, and
> that minor changes - say, just before going into production use, per
> Murphy - would break it.

Not really.  The most common false positive for uninitialized variable
warnings takes this form:

    T* ptr_T;
    bool ptr_is_valid = false;
    if (some_fancy_test()) {
	ptr_T = foo();
	ptr_is_valid = true;
    }
    do_something_else();
    if (ptr_is_valid) {
	do_something_with(ptr_T);
    }

GCC currently will falsely report that ptr_T might be used uninitialized,
because it does not see the correlation between ptr_is_valid and ptr_T.

Something like gated SSA can determine that only the value returned by
foo() can reach the first argument of do_something_with(), but there
is nothing brittle about this coding style.  But we don't use a gated
form, so we throw away the needed information.

My concern is that if we insist that a separate, weaker flow pass be used
to do unintialized variable warnings, just to be independent of -O, then
we'll wind up running it twice, and the compiler will be slower.
	    



More information about the Gcc mailing list