<br><br><div class="gmail_quote">On Fri, Jan 2, 2009 at 11:43 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">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 class="Wj3C7c"><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>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 class="Apple-style-span" style="font-family: 'courier new', monospace;">diciu$ ~/Downloads/checker-137/clang -x c test.c   -checker-cfref  </span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">ANALYZE: test.c main</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">test.c:6:2: warning: Pass-by-value argument in function is undefined.</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">        strcpy(t, g);</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">        ^      ~</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">1 diagnostic generated.</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br></span></div><div><br></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">diciu$ ~/Downloads/checker-137/clang -x c test.c   -warn-uninit-values</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">test.c:6:9: warning: use of uninitialized variable</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">        strcpy(t, g);</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">               ^</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">test.c:6:12: warning: use of uninitialized variable</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">        strcpy(t, g);</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">                  ^</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">2 diagnostics generated.</span></div><div> </div></div>test.c is:<div><br><div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">#include <string.h></span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br></span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">int main()</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">{</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: 'courier new', monospace;"> </span></span><span class="Apple-style-span" style="font-family: 'courier new', monospace;">char * t, * g;</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">      </span></span><span class="Apple-style-span" style="font-family: 'courier new', monospace;">strcpy(t, g);</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;"><br></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-style-span" style="font-family: 'courier new', monospace;">        </span></span><span class="Apple-style-span" style="font-family: 'courier new', monospace;">return 0;</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace;">}</span></div><div><br></div><br clear="all"><br>
</div></div>