[cfe-dev] -Wuninitialized

Ted Kremenek kremenek at apple.com
Tue Mar 9 14:33:41 PST 2010


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.

Thoughts?  Should we hook -Wuninitialized up to (1)?



More information about the cfe-dev mailing list