[cfe-dev] Non-deterministic diagnostics for -Wuninitialized.

Enea Zaffanella zaffanella at cs.unipr.it
Thu Jan 10 06:34:44 PST 2013


On 01/10/2013 03:19 PM, Csaba Raduly wrote:
> On Thu, Jan 10, 2013 at 1:21 PM, Enea Zaffanella  wrote:
>> On 01/10/2013 01:09 PM, Csaba Raduly wrote:
>>> Which version of clang are you using? I got the same md5sum (different
>>> from both of yours) ten times in a row with
>>>
>>> $ clang -v
>>> clang version 3.3 (trunk 171717)
>>> Target: x86_64-unknown-linux-gnu
>>> Thread model: posix
>>>
>>>
>>> Csaba
>>>
>>
>> $ clang -v
>> clang version 3.3 (trunk 171957)
>>
>> Target: x86_64-unknown-linux-gnu
>> Thread model: posix
>>
>> (built in debug mode).
>
> It may be something the debug mode prints (my clang is Release+Asserts).
>
> There seems to be two different outputs. Perhaps if you showed them
> instead of the md5sum, it would be easier to spot the difference.
>
> Csaba


The difference is just the order of the two diagnostics.

====================================================================
$ clang -Wuninitialized -fsyntax-only bug.c
bug.c:3:7: warning: variable 'b' is uninitialized when used here
       [-Wuninitialized]
   a = b;
       ^
bug.c:2:8: note: initialize the variable 'b' to silence this warning
   int b, c;
        ^
         = 0
bug.c:4:7: warning: variable 'c' is uninitialized when used here
       [-Wuninitialized]
   a = c;
       ^
bug.c:2:11: note: initialize the variable 'c' to silence this warning
   int b, c;
           ^
            = 0
2 warnings generated.
====================================================================


====================================================================
$ clang -Wuninitialized -fsyntax-only bug.c
bug.c:4:7: warning: variable 'c' is uninitialized when used here
       [-Wuninitialized]
   a = c;
       ^
bug.c:2:11: note: initialize the variable 'c' to silence this warning
   int b, c;
           ^
            = 0
bug.c:3:7: warning: variable 'b' is uninitialized when used here
       [-Wuninitialized]
   a = b;
       ^
bug.c:2:8: note: initialize the variable 'b' to silence this warning
   int b, c;
        ^
         = 0
2 warnings generated.
====================================================================

These diagnostics are produced by the analyzer; the analyzer goes 
through the list of CFG blocks; if I remember correctly, the iterators 
on these are in general non-deterministic.

Enea.




More information about the cfe-dev mailing list