This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: named warnings & individual warning control

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;
    if (ptr_is_valid) {

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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]