Andrew Koenig
Fri Apr 30 23:15:00 GMT 1999

Mark> Yes, I do.  What exactly are the new requirements?

Thanks for the quick response!

Initialization is changed in two contexts:

     1. An expression of the form T()  (with no arguments in the ())

     2. An element of an array that is brace-initialized, but
        for which there is no corresponding initializer (i.e.
	the elements that are left over when you run out of

The standard says that such objects are default-initialized.

The revision introduces a new concept called ``value-initialized,''
defined as follows:

	To value-initialize an object of type T means:

	If T is a class type with a user-declared constructor,
	then the default constructor for T is called (and the
	initialization is ill-formed if T has no accessible
	default constructor);

	If T is a non-union class type without a user-declared
	constructor, then every non-static data member and base-class
	component of T is value-initialized;

	If T is an array type, then each element is value-initialized;

	Otherwise, the storage for the object is zero-initialized.

The difference is relevant for class types that do not have a
user-defined constructor, but which have members or base class
components that do have user-defined constructors.  Such classes
appear to be PODs from the outside, but aren't PODs because they
have constructors buried within them.  I call such classes
pseudoPODs, though of course that term isn't official :-)

Anyway, the point is that if we have a class such as

	struct T {
	       int a;
	       X x;

The standard says that whether T().a is defined depends on whether
X has a constructor.  The revision says that T().a is always zero,
because T does not have a user-defined constructor.

Hope this helps.       --ark

More information about the Gcc-bugs mailing list