<div dir="ltr"><div><div>Hi!<br><br>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?<br><br></div>Regards,<br></div>Gábor<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 1 September 2015 at 20:06, Daniel Marjamäki <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><span class="">>> 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?<br>
<br>
> You seem to have substituted a lot of false positives for a lot of false negatives.
</span><div><br>
Thanks for looking!<br>
<br>
It is just a proof of concept patch. I wanted it to be accurate. The finished patch will have fewer false negatives for sure.<br>
<br>
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.<br>
<br>
If that means the amount of FPs will be acceptable on real code, I am fine with that.<br>
<br>
I have been told that we shouldn't even warn for:<br>
<br>
    void foo(int x) {<br>
        unsigned y;<br>
        y = x;<br>
    }<br>
<br>
.. 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.<span class=""><br>
<br>
Best regards,<br>
Daniel Marjamäki<br>
<br>
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma;font-size:13px">
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt">..............................<wbr>..............................<wbr>..............................<wbr>........................</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:black;font-size:8pt">Daniel Marjamäki
</span><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt">Senior Engineer</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8.5pt" lang="EN-US">Evidente ES East</span><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-US"> AB<span> 
</span>Warfvinges väg 34<span>  </span>SE-112 51 Stockholm<span>  </span>Sweden </span>
</p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-US"></span> </p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-GB">Mobile</span><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-GB">:<span>                
</span>+46 (0)709 12 42 62</span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-GB"></span><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-GB">E-mail:<span>   
</span><span>             <a href="mailto:Daniel.Marjamaki@evidente.se" target="_blank">
Daniel.Marjamaki</a></span><a href="mailto:Daniel.Marjamaki@evidente.se" target="_blank">@evidente.se</a><span>  <wbr>   
</span><span>                 </span></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';color:gray;font-size:8pt" lang="EN-GB"></span> </p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:'Arial','sans-serif';font-size:8pt" lang="EN-GB"><a href="http://www.evidente.se" target="_blank">www.evidente.se</a></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</span></div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr" id="m_8965251300087822452divRpF264037"><font size="2" face="Tahoma" color="#000000"><b>Från:</b> Matthew Del Buono [<a href="mailto:mpdelbuono@gmail.com" target="_blank">mpdelbuono@gmail.com</a>]<br>
<b>Skickat:</b> den 1 september 2015 17:47<br>
<b>Till:</b> Daniel Marjamäki<br>
<b>Kopia:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<b>Ämne:</b> Re: [cfe-dev] [StaticAnalyser][RFC] New checker, -Wsign-compare without the noise<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
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?<br>
<br>
</blockquote>
<div><br>
</div>
<div>You seem to have substituted a lot of false positives for a lot of false negatives.
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>- Matthew P. Del Buono</div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>

<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>