<br><br><div class="gmail_quote">On Sat, Jan 3, 2009 at 11:09 AM, Cristian Draghici <span dir="ltr"><<a href="mailto:cristian.draghici@gmail.com">cristian.draghici@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Fri, Jan 2, 2009 at 11:43 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><div></div><div><br>
On Jan 2, 2009, at 2:18 AM, Cristian Draghici wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi<br>
<br>
I've noticed that scan-build in the latest version of the checker (137) disables the check for uninit values (-warn-uninit-values).<br>
Is there a reason behind that?<br>
<br>
<br>
Thank you,<br>
Cristi<br>
</blockquote>
<br></div></div>
In the static analyzer, checking for uninitialized values, just as with checking for null dereferences, is done as part of the core path-sensitive logic used for -checker-cfref and -checker-simple.  It isn't controlled by -warn-uninit-values.<br>


<br>
The -warn-uninit-values option performs a fast check for uses of uninitialized values that is similar to GCC's -Wuninitialized.  It should be thought of as a cheap check that can be used (one day) as a compiler warning rather than a deep check done by the static analyzer.  The checking for uninitialized values done by the static analyzer is far more precise.<br>


<br>
Some of these options should probably be renamed to avoid such confusion.</blockquote><div><br></div></div></div><div>My confusion was actually caused by the different output of "-checker-cfref" vs "-warn-uninit-values".</div>

<div><br></div><div>In the warning below shouldn't clang say "Pass-by-value argument in function is uninitialized"?</div><div>English is not my native language so I may be wrong but I tend to equate "undefined" with "undeclared" (as in lacking definition).</div>

<div><br></div><div><span style="font-family:'courier new', monospace">diciu$ ~/Downloads/checker-137/clang -x c test.c   -checker-cfref  </span></div><div><span style="font-family:'courier new', monospace">ANALYZE: test.c main</span></div>

<div><span style="font-family:'courier new', monospace">test.c:6:2: warning: Pass-by-value argument in function is undefined.</span></div><div><span style="font-family:'courier new', monospace">        strcpy(t, g);</span></div>

<div><span style="font-family:'courier new', monospace">        ^      ~</span></div><div><span style="font-family:'courier new', monospace">1 diagnostic generated.</span></div>
<div><span style="font-family:'courier new', monospace"><br></span></div><div><br></div><div><span style="font-family:'courier new', monospace">diciu$ ~/Downloads/checker-137/clang -x c test.c   -warn-uninit-values</span></div>

<div><span style="font-family:'courier new', monospace">test.c:6:9: warning: use of uninitialized variable</span></div><div><span style="font-family:'courier new', monospace">        strcpy(t, g);</span></div>

<div><span style="font-family:'courier new', monospace">               ^</span></div><div><span style="font-family:'courier new', monospace">test.c:6:12: warning: use of uninitialized variable</span></div>

<div><span style="font-family:'courier new', monospace">        strcpy(t, g);</span></div><div><span style="font-family:'courier new', monospace">                  ^</span></div>
<div><span style="font-family:'courier new', monospace">2 diagnostics generated.</span></div><div> </div></div>test.c is:<div><br><div><div><span style="font-family:'courier new', monospace">#include <string.h></span></div>

<div><span style="font-family:'courier new', monospace"><br></span></div><div><span style="font-family:'courier new', monospace">int main()</span></div>
<div><span style="font-family:'courier new', monospace">{</span></div><div><span style="white-space:pre"><span style="font-family:'courier new', monospace">    </span></span><span style="font-family:'courier new', monospace">char * t, * g;</span></div>

<div><span style="white-space:pre"><span style="font-family:'courier new', monospace">    </span></span><span style="font-family:'courier new', monospace">strcpy(t, g);</span></div>
<div><span style="font-family:'courier new', monospace"><br></span></div><div><span style="white-space:pre"><span style="font-family:'courier new', monospace">   </span></span><span style="font-family:'courier new', monospace">return 0;</span></div>

<div><span style="font-family:'courier new', monospace">}</span></div><div><br></div><br clear="all"><br>
</div></div>
</blockquote></div><div><br></div>Oh, nevermind, I get it.<div><br><span class="Apple-style-span" style="font-family: 'courier new'; font-size: 12px; ">"Pass-by-value argument in function is undefined" probably refers to the value pointed to by the char pointer as being undefined, which it is.</span><br clear="all">
<br>
</div>