[cfe-dev] -Wuninitialized

Douglas Gregor dgregor at apple.com
Tue Mar 16 15:09:13 PDT 2010


On Mar 9, 2010, at 2:39 PM, Chris Lattner wrote:

> 
> On Mar 9, 2010, at 2:33 PM, Ted Kremenek wrote:
> 
>> I am soliciting opinions about what to do about -Wuninitialied.  Clang currently doesn't implement it.  It does, however, have:
>> 
>> (1) A simple flow-sensitive uninitialized values dataflow analysis in libAnalysis (currently usable as part of the static analyzer)
>> 
>> (2) Path-sensitive checking for uninitialized values in the static analyzer.  This is far more precise than what GCC does at -Wuninitialized.
>> 
>> I have heard numerous requests for -Wuninitialized, and other requests to have it run even at -O0 (which gcc does not do since -Wuninitialized is implemented as part of the optimizer).  The question is that given (2) should we implement -Wuninitialized at all?  If so, does (1) seem like a reasonable solution?
>> 
>> More details about (1):
>> 
>> (a) Not heavily performance optimized, but it that can be done over time
>> 
>> (b) Doesn't check field values; does a simple flow-sensitive analysis of variables within a function
>> 
>> (c) Sometimes GCC gets some amount of inter-procedural analysis with -Wuninitialized because of the inliner.  This is something we wouldn't consider doing in Clang.  For true inter-procedural uninitialized values checking, I prefer that to be (one day) in the static analyzer.
> 
> 
> I think that #1 could be very useful, particularly if it runs fast.  To me, it is more important that it behave predictably and catch the obvious cases than it is for it to be super tricky and catch uses in inlined functions etc like GCC tries to do.

+1

	- Doug



More information about the cfe-dev mailing list