http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202

--- Comment #4 from Thiago Macieira <thiago at kde dot org> 2012-08-08 14:53:13 
UTC ---
(In reply to comment #3)
> Note that even for the uninitialized use case we warn for functions
> that may be never executed at runtime.  So - are you happy with the
> definitive warning if the free () call happens unconditionally when
> the function is entered?

I'm not sure I follow your reasoning. Please bear with me.

If GCC can prove that the function will be called with a non-heap object, print
the warning, even if the function in question never gets executed. That is,
after inlining, code like:

extern Data shared_null;
void dispose()
{
    free(&shared_null);
}

*should* print the warning, regardless of whether dispose() ever gets run.

My point was that the code that GCC was seeing, after inlining, was:

void f()
{
    if (shared_null.refcount == 0)
       free(&shared_null);
}

In which case, the call to free() isn't unconditional. In this case, the
warning should either be suppressed, or indicate that it's only a possibility
instead of being assertive.

Reply via email to