-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/06/11 07:16, David Brown wrote:
> > I would say it's better to have false positives in cases like this, > than false negatives, because there are easy ways to remove the > false positives. It is exactly in cases like this, with complex > conditional initialisations, that you want the warning to be sure > that you've covered everything. My impression (without having done > careful testing) is that the compiler is quite good at spotting in > which paths the variable is initialised and uninitialised, and that > this has improved with newer versions of gcc. This means the > warning has the potential to be more accurate and thus more > useful. This is an issue that has been debated several times; some prefer a minimal set of false positives others want an expanded set. Anything we choose is going to make a group of developers unhappy. Things continue to improve, largely because we continue to find paths in the CFG that are unexecutable for various reasons. I few years ago I suggested a multi-phase approach where we would gather some information early in the pipeline to satisfy those who want the maximal set of warnings. We would then re-run the analysis late in the pipeline (like we do now) for those who prefer a minimal set of warnings. Someone with an interest could resurrect that patch without too much trouble. > > In cases when you know you've initialised the variable in all > possible use cases, but the compiler can't see that, then you can > initialise the variable to itself (as long as you don't use the > -Winit-self flag) to disable the warning on that variable. In the > great majority of cases, you can also initialise the variable to > some value without having any noticeable effect on the program size > or speed. I would actually recommend against those kind of initializations; while it avoids warnings now, it can mask problems later. jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJO3kG8AAoJEBRtltQi2kC7kYEH/1i6jR8oMURCOh2uif53mEQk ZO8RuT4t+Rn4c80EIPSpMk3rkQOdnb/9cTnLOXE8m1G8jC7dAYgMzaMosgZMB6EI rwPy0QI8fXHpwbugtCci5ndDTMdxMFUyriFmLFVCM3y93STSurPGWLeHN+tVMlV6 QAMdGEBFyuIeZ39hHdO8K/GcRXHFP6D/MOKEDRaXbe6ejRjn9k0oX81xinTboasw YLguNbYodSHKTW1kGRCwWCKdk9ibE5amB3/rDAtWfeWaic0GcTmCBbC3Lbi+KXDg bonHuBWK8hVB7YDz/AYbzd/ocI+qv2UfCbosJkIQ4Znyvvlk4lx/xL1TNzIkUqA= =2Kon -----END PGP SIGNATURE-----