[cfe-dev] Static Analyzer false positive looking into impossible branch
Joerg Sonnenberger
joerg at britannica.bec.de
Mon Apr 16 15:05:30 PDT 2012
On Mon, Apr 16, 2012 at 10:24:36AM -0700, Ted Kremenek wrote:
> Top-of-tree doesn't emit a warning for this code. Before we had
> (basic) inter-procedural analysis, it would be reasonable for the
> analyzer to warn, since it wouldn't look across logic between function
> boundaries. Essentially, it would be as if you had written:
>
> #include <stdlib.h>
>
> int never();
>
> int main()
> {
> void *p = 0;
> int n = 0;
> if ( never() ) {
> p = malloc ( n ); // warning: malloc size 0
> free(p);
> }
>
> return 0;
> }
It already works as expected if never() has attribute noreturn.
Joerg
More information about the cfe-dev
mailing list