It does look like you got to it before I did. The build I'd been using was at least a week and change old. After a sync, rebuild, and recheck, it appears to no longer give that false positive.<div><br></div><div>Unfortunately, it still gives a false positive where the reference is captured in a ctor and then one of the member functions has a side effect which initializes it.</div>
<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace">class SideEffect</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">{</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">public:</font></div></div><div><div>
<font class="Apple-style-span" face="'courier new', monospace">  SideEffect(int *pi); // caches pi in i_</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  void Read(int *pi); // copies *pi into *i_</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">private:</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  int *i_;</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">};</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div>
<font class="Apple-style-span" face="'courier new', monospace">extern void UseMe(int i);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div>
<div><font class="Apple-style-span" face="'courier new', monospace">int main(const int /* argc */, const char *const /* argv */[]) {</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  int i;</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  SideEffect se(&i);</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  int j = 1;</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  se.Read(&j);</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  UseMe(i);</font></div></div>
<div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  return 0;</font></div></div><div><div>
<font class="Apple-style-span" face="'courier new', monospace">}</font></div></div></blockquote><div><div><br></div><div>Compiling this yields:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div><div><font class="Apple-style-span" face="'courier new', monospace">/home/nherring/test.cc:23:3: warning: Function call argument</font></div></div></div><div><div><div><font class="Apple-style-span" face="'courier new', monospace">      is an uninitialized value</font></div>
</div></div><div><div><div><font class="Apple-style-span" face="'courier new', monospace">  UseMe(i);</font></div></div></div><div><div><div><font class="Apple-style-span" face="'courier new', monospace">  ^     ~</font></div>
</div></div><div><div><div><font class="Apple-style-span" face="'courier new', monospace">1 warning generated.</font></div></div></div></blockquote><div><div><br></div><div><br></div><div>
It seems that, any pointer value could get captured as state inside an object if its ctor or member function takes that pointer argument. Is the checker now conservative, but only across one function call, rather than conservative in the sense of objects capturing state?</div>
<div><br></div><div>In the meanwhile, your commentary for the change suggests that the conservative C checker simply believes that these values (referenced via pointers) <i>could</i> have been set, and thus won't warn that it wasn't set, even though its entirely possible that the bound function and its children also don't set the value (perhaps only under certain code paths). Is there any future plan to eventually provide stronger safeguards, e.g., by custom attributes marking certain arguments as necessarily or conditionally (based on some return value) initialized, and/or captured by the object beyond the scope of the method call.</div>

<div><br></div><div>Thx,</div><div>nh<br><br><div class="gmail_quote">On Wed, Apr 6, 2011 at 1:07 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi Nathan,<div><br></div><div>This may already be fixed:</div><div><br></div><div><a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=128557" target="_blank">http://llvm.org/viewvc/llvm-project?view=rev&revision=128557</a></div>

<div><br></div><div>What version of the analyzer are you using?</div><div><br></div><div>Ted</div><div><br><div><div><div><div></div><div><div>On Apr 5, 2011, at 6:02 PM, Nathan Herring wrote:</div><br></div></div>
<blockquote type="cite"><div><div><div></div><div>Ran into cases running the clang analyzer against some of my code<br>where an otherwise uninitialized local is initialized by a function<br>call or method call, but clang doesn't realize and reports the next<br>

access as uninitialized or garbage. This appears to have at least one<br>representative bug, 9283.<br><br>I'm new to clang, having just gotten an enlistment and source indexing<br>yesterday, and would like to help work toward contributing a patch to<br>

fix this (and learn the ropes along the way).<br><br>I've found the checker involved in CallAndMessageChecker.cpp, but this<br>appears to be downstream of the problem (not setting the value of the<br>SVal to something other than uninitialized). I've found<br>

ExprEngine::VisitCall and VisitCXXMemberCallExpr, which is probably<br>the top of the world where I'd look at function arguments and look for<br>pointers to non-const Ts and non-const T references and make them<br>potential binds. Sound good so far? Next -- how do you know whether<br>

the value will be set in the function call? Can we make it more<br>explicit by annotating the function arguments with something akin to<br>SAL's __out? Or does this walk down the AST into the call and sees if<br>the child (or its child, etc., etc.) do the right thing?<br>

<br>I've leafed through some of the Doxygen content for clang and the<br>InternalsManual page, but haven't seen exactly how this would play<br>out. Any pointers would be helpful!<br><br>Thx in advance,<br>nh<br></div>

</div>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>

</div></blockquote></div><br></div></div></div></blockquote></div><br></div></div>