<div>I totally agree. If you have such constrain then you should express it in code, for example using do-while or assert, or why just not initialize the value?<br><div class="gmail_extra"><br><div class="gmail_quote">On Aug 25, 2016 08:15, "Sean Eveson via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">Hi,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I've seen the analyzer find real problems where loops are not executed and think this is very useful. Personally I'd rather see the warnings and add asserts, which makes it clearer that 'nr' must be greater than 1, making it less likely someone will add an incorrect call in the future. While that is a preference for avoiding false negatives over false positives, I think it is reasonable in this case given there is no analysis across translation units.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">You tend to get false positives when the Analyzer can't see any calls to the function, so doesn't know 'nr' can never be less than 1. You can get false negatives when the analyzer can only see some of the calls.</div><div class="gmail_extra"><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Web Regular","Segoe UI Symbol","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18.85px">Sean Eveson</span><br style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Web Regular","Segoe UI Symbol","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18.85px"><span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Web Regular","Segoe UI Symbol","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18.85px">SN Systems - Sony Computer Entertainment Group</span><br></div></div></div><div class="elided-text">
<br><div class="gmail_quote">On Thu, Aug 25, 2016 at 8:55 AM, Daniel Marjamäki via cfe-dev <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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
One more email about false positives.<br>
<br>
I see many false positives in code like this:<br>
<br>
    int f(int nr) {<br>
      int x;<br>
      for (int i = 0; i < nr; ++i) {<br>
        x = i;<br>
      }<br>
      return x;<br>
    }<br>
<br>
Theoretically, if "nr" is less than 0 then the return value will be uninitialized.<br>
<br>
As far as I have seen we know that such loops are executed at least once very often. I can't remember a TP where it was possible that such loop code would not be executed.<br>
<br>
Can we try to fix this so the analyzer will be silent for the above code? I would like that if the variable is unconditionally written in the loop code there should be no warning.<br>
<br>
Best regards,<br>
Daniel Marjamäki<br>
<br>
..............................<wbr>..............................<wbr>..............................<wbr>........................<br>
Daniel Marjamäki Senior Engineer<br>
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden<br>
<br>
Mobile:                 <a href="tel:%2B46%20%280%29709%2012%2042%2062" value="+46709124262" target="_blank">+46 (0)709 12 42 62</a><br>
E-mail:                 <a href="mailto:Daniel.Marjamaki@evidente.se" target="_blank">Daniel.Marjamaki@evidente.se</a><br>
<br>
<a href="http://www.evidente.se" rel="noreferrer" target="_blank">www.evidente.se</a><br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">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>
</blockquote></div><br></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></div>