[cfe-dev] [StaticAnalyser][RFC] New checker, -Wsign-compare without the noise

Matthew Del Buono via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 1 08:47:55 PDT 2015

> I attach a simple proof of concept checker. It will just warn if there is
> an assignment and RHS is a known negative value. Do you have opinions about
> the design? Should some alternative approach be used?
You seem to have substituted a lot of false positives for a lot of false

Why not look to see if the value cannot be provably non-negative? That
would resolve the false positive you showed above, but still capture cases
where the case only *might* be negative (rather than being guaranteed to be
negative). In fact, I think the most interesting case is those where an
off-by-one error or some other hidden defect has caused a scenario where
almost all cases are positive, but left a couple cases open that the
developer did not realize could be negative. Warning in these scenarios
that the conversion could be unsafe would be very powerful, I think.

- Matthew P. Del Buono
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150901/9ff415d8/attachment.html>

More information about the cfe-dev mailing list