[cfe-dev] new -Wuninitialized implementation in Clang

Alexei Svitkine alexei.svitkine at gmail.com
Sun Feb 6 06:46:41 PST 2011


> Another refinement of this, it would be really nice to add an attribute((silence_uninitialized)) attribute, which would allow turning the warning off for a particular variable.  This could be used by proponents of "I know my code is safe and I don't want to initialize the variable".  It is good IMO to have an attribute here, because then that desire is explicit in the code.  This should be mentioned in the compatibility.html file.

Except when someone changes that code later and what was once
something that was a false positive becomes real bug, but the
attribute suppresses the legitimate warning. Same goes for the always
initialize your variables approach.

IMHO, a warning that has a lot of false positives should not be on by
default. Sure, offer it as an option to be compatible with people who
expect it to be there for GCC, but please don't turn it on by default
if most of what it reports is noise.

Also, please make a -Wuninitialized-full or something similar that
instead runs the static analysis version which does give the correct
results. Sure, it may be slow (so it might not make sense for all
builds), but it's something that is much more useful to find bugs in
code without noise.

-Alexei




More information about the cfe-dev mailing list