<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Erik,<div>      I too have been bothered by the lack of sophistication in static analyzers, my most recent was</div><div>something like this:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>int foo ()</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>if (...) {</div><div><span class="Apple-tab-span" style="white-space:pre">                   </span>return x;</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>} else switch (...) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>case 1: return y;</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>default: return z;</div><div><span class="Apple-tab-span" style="white-space:pre">           </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>}</div><div><br></div><div>and the compiler complained that the function could run-off-the-end without returning a value.!.</div><div><br></div><div>(the problem was with gcc, I have not tried clang on my code yet, since that would require clang/llvm</div><div>self-hosting, which I am not sure works yet ?)</div><div><br></div><div><br></div><div><br></div><div>as this email-thread has evolved into a discussion of what is necessarily missed by not doing</div><div>inter-procedural (whole-program) analysis,  I am still confounded by what is not being done that</div><div>could be done with intra-procedural analysis which is very much more doable  (and again, maybe</div><div>clang is already doing better in that department than gcc, but I have not yet done the experiment</div><div>to find out...)</div><div><br></div><div><br></div><div>so, what I am really trying to say is this:   static analysis (and also dynamic analysis) should be</div><div>implemented by folks that are very familiar with optimization theory, since avoiding false-positives</div><div>is very often necessarily going to rely on some form of iterative-data-flow analysis, which while</div><div>fairly simple conceptually, isn't typically understood well enough by pure "front-end" only folks</div><div>that are traditionally given the task of implementing these analyses.  --- well, perhaps I am over-</div><div>analyzing the situation a bit,  but I do think things could stand some improvement anyway.</div><div><br></div><div><br></div><div>just my $0.02, your milage may vary...</div><div><br></div><div><br></div><div>-Peter Lawrence.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><div><div>On May 13, 2011, at 3:36 AM, <a href="mailto:cfe-dev-request@cs.uiuc.edu">cfe-dev-request@cs.uiuc.edu</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">I created a bug report some time ago <a href="http://llvm.org/bugs/show_bug.cgi?id=8914">http://llvm.org/bugs/show_bug.cgi?id=8914</a> I realize that fixing this is non-trivial, but it would be nice if the analyzer could at least handle the following:</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">if foo():</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">       </span>x = 5</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">else:</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">  </span>exit()</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">bar(x)</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">without complaining that x might be uninitialized.</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">Kind regards,</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Monaco" size="3" style="font: 12.0px Monaco">Erik</font></p> </blockquote></div><br></div></body></html>