[cfe-dev] Static analyzer: possible memory leak false positive?

Eitan Adler lists at eitanadler.com
Fri Sep 14 12:15:00 PDT 2012


On 14 September 2012 13:54, Anna Zaks <ganna at apple.com> wrote:
> I think it is reasonable to expect the analyzer not to warn in this particular case.

FWIW, I plan to fix this case. But, it would be nice to differentiate
the output from a legitimate one.

> However, constructing a rule on when the error should be suppressed is tricky. One possibility is that the analyzer should dismiss the warning only if it can prove that nothing allocates memory after the leak. For example, if main calls foo() after the leak is detected, we should warn, unless we can prove that foo() does not allocate memory. This rule would silence the warning in this case, but might not work in case where foo() is called after the leak and the analyzer does not know what the effect of foo()  will be.

+1

> Joerg, I think that, since the analyzer looks at preprocessed code, redefinition of main would not be an issue.

I believe his point is that since someone may redefine main, and
therefore inherit a leak, which is non-existent in the original code.
In other words, it may not be an issue for this program, but its still
nice to cleanup after oneself.


-- 
Eitan Adler




More information about the cfe-dev mailing list