[cfe-dev] Why does scan-build disable check for uninit values?

Cristian Draghici cristian.draghici at gmail.com
Sat Jan 3 01:43:18 PST 2009


On Sat, Jan 3, 2009 at 11:09 AM, Cristian Draghici <
cristian.draghici at gmail.com> wrote:

>
>
> On Fri, Jan 2, 2009 at 11:43 PM, Ted Kremenek <kremenek at apple.com> wrote:
>
>>
>> On Jan 2, 2009, at 2:18 AM, Cristian Draghici wrote:
>>
>>  Hi
>>>
>>> I've noticed that scan-build in the latest version of the checker (137)
>>> disables the check for uninit values (-warn-uninit-values).
>>> Is there a reason behind that?
>>>
>>>
>>> Thank you,
>>> Cristi
>>>
>>
>> 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.
>>
>> 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.
>>
>> Some of these options should probably be renamed to avoid such confusion.
>
>
> My confusion was actually caused by the different output of
> "-checker-cfref" vs "-warn-uninit-values".
>
> In the warning below shouldn't clang say "Pass-by-value argument in
> function is uninitialized"?
> English is not my native language so I may be wrong but I tend to equate
> "undefined" with "undeclared" (as in lacking definition).
>
> diciu$ ~/Downloads/checker-137/clang -x c test.c   -checker-cfref
> ANALYZE: test.c main
> test.c:6:2: warning: Pass-by-value argument in function is undefined.
>         strcpy(t, g);
>         ^      ~
> 1 diagnostic generated.
>
>
> diciu$ ~/Downloads/checker-137/clang -x c test.c   -warn-uninit-values
> test.c:6:9: warning: use of uninitialized variable
>         strcpy(t, g);
>                ^
> test.c:6:12: warning: use of uninitialized variable
>         strcpy(t, g);
>                   ^
> 2 diagnostics generated.
>
> test.c is:
> #include <string.h>
>
> int main()
> {
> char * t, * g;
>  strcpy(t, g);
>
> return 0;
> }
>
>
>
>
Oh, nevermind, I get it.
"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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090103/f8b18c3f/attachment.html>


More information about the cfe-dev mailing list