[cfe-dev] [StaticAnalyser][RFC] New checker, -Wsign-compare without the noise
Gábor Horváth via cfe-dev
cfe-dev at lists.llvm.org
Fri Feb 17 08:18:20 PST 2017
Hi!
Having a check with less false positives is certainly useful. What is the
state of this? Did you try it on some projects? Did you get promising
results?
Regards,
Gábor
On 1 September 2015 at 20:06, Daniel Marjamäki <cfe-dev at lists.llvm.org>
wrote:
> >> 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
> negatives.
>
> Thanks for looking!
>
> It is just a proof of concept patch. I wanted it to be accurate. The
> finished patch will have fewer false negatives for sure.
>
> My primary goal is to avoid obvious FPs. When it is obvious that the
> signed value can't be negative there should be no warning about loss of
> sign.
>
> If that means the amount of FPs will be acceptable on real code, I am fine
> with that.
>
> I have been told that we shouldn't even warn for:
>
> void foo(int x) {
> unsigned y;
> y = x;
> }
>
> .. as developers often know that some function parameters are always
> positive. if we want to properly warn about that we should lookup all "foo"
> function calls and see if the parameter is negative sometimes.
>
> Best regards,
> Daniel Marjamäki
>
> ............................................................
> ......................................................
>
> Daniel Marjamäki Senior Engineer
>
> Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
>
>
>
> Mobile: +46 (0)709 12 42 62
>
> E-mail: Daniel.Marjamaki <Daniel.Marjamaki at evidente.se>
> @evidente.se <Daniel.Marjamaki at evidente.se>
>
>
>
> www.evidente.se
> ------------------------------
> *Från:* Matthew Del Buono [mpdelbuono at gmail.com]
> *Skickat:* den 1 september 2015 17:47
> *Till:* Daniel Marjamäki
> *Kopia:* cfe-dev at lists.llvm.org
> *Ämne:* Re: [cfe-dev] [StaticAnalyser][RFC] New checker, -Wsign-compare
> without the noise
>
>
>> 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
> negatives.
>
> 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
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170217/23983799/attachment.html>
More information about the cfe-dev
mailing list