[cfe-dev] Suppress: Static Analysis false positive.

Ted Kremenek kremenek at apple.com
Thu Feb 25 10:29:08 PST 2010

On Feb 25, 2010, at 9:13 AM, Steven Osborn wrote:

> I've dug through the documentation, but I can't find anything to help
> me suppress this particular warning.

In general I'm not so found of a general "silence this warning" annotation for the static analyzer, as really the goal is to make the analyzer smarter.  Annotations (e.g., attribute(noreturn)) that educate the analyzer about program semantics are one thing, and they are good to use from a software engineering perspective because they document the assumptions of the code.  But for cases where the analyzer is just outright confused, I'd prefer we get bug reports so we can just make it smarter.  That way it benefits everyone who uses the analyzer.  Chances are if you are seeing a false positive someone else has seen it too.

The analyzer can be a lot more clever than a compiler warning, so there we should never approach a false positive as "this is something the analyzer could never figure out."  Even if solving the general analysis problem is hard, often identifying a case where the analyzer would have difficulty is trivial, and in such cases we can take a conservative approach of not issuing a warning.

More information about the cfe-dev mailing list