This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: missing initializer warnings

I'm following up on my own post about the unintialized structure member
warning. I've trawled through the patches archive and found the mail
concerning its insertion into egcs
( and
followups). I guess I should have done that first - let that be a lesson
to me.

I think Jeffrey Law hits it on the head -- there are too many false
positives. And the way to inhibit the warning by putting explicit zeroes
in is just too annoying.

Also, having had a chance to sleep on it, I think this warning is
*dangerous*, because it can lead to a false sense of security. With it,
egcs only warns about some cases of implicit initialization to zero.
There are other cases where *uninitialized* members are not diagnosed.
Consider the following
	struct S
	  int a;
	static S s; 

Here the constructor S::S() does not initialize member a and leaves it
*undefined*. egcs emits no warning either during parsing the
constructor, or during its application. This problem *has* bitten me
when I added a member variable and forgot to initialize it in the
constructors -- I can't recall being bitten by the initialized to zero

The problem I see is that both initialization by initializer list and by
constructor can be thought of as initialization, and I, the programmer,
know I'm being warned about implicit zero initialization, I might
therefore (reasonably?) expect to be warned about the far more dangerous
uninitialized member. When optimization is on I'm warned about possible
unintialized automatic variables. I know members of the `this' object
aren't the same as automatics, but they can look like it in the source
code. Actually detecting this kind of error might well be quite hard.

Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]