feature suggestion/request -- Take 2

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Tue Jun 8 15:47:00 GMT 1999


> Do you think this is desirable? 

No. If you don't want a check on the syntactic level, you really want
to test whether data being read had been initialized before, be it in
the constructor or by some other means.

If you want such functionality, you should use Purify or
-fcheck-memory-usage.

> Would this be hard to implement?

Yes. Consider

	class Bla {
	      int k;
	      int j;
              void foo(){
                 j = 5;
              }

	      Bla () {
		  foo();
	      }
	};

Do you want to compiler to complain about j not being initialized in
the ctor? In the end, j *is* initialized in the ctor. Statically
detecting whether some memory location is initialized is the halting
problem, so it is not solvable.

You *really* want to initialize members in the
member-initializer-lists anyway, because it guarantees you
initialization.

Regards,
Martin


More information about the Gcc-bugs mailing list