Are the following statements correct?
- An uninitialized reference is considered zero-initialized.
- An uninitialized scalar is considered default-initialized.
- Any other uninitialized entity is not considered zero-initialized nor default-initialized.
They are based on [dcl.init.general/6] (bold emphasis mine):
To zero-initialize an object or reference of type
Tmeans:
- if
Tis a scalar type, the object is initialized to the value obtained by converting the integer literal0(zero) toT;- if
Tis a (possibly cv-qualified) non-union class type, its padding bits are initialized to zero bits and each non-static data member, each non-virtual base class subobject, and, if the object is not a base class subobject, each virtual base class subobject is zero-initialized;- if
Tis a (possibly cv-qualified) union type, its padding bits are initialized to zero bits and the object's first non-static named data member is zero-initialized;- if
Tis an array type, each element is zero-initialized;- if
Tis a reference type, no initialization is performed.
and on [dcl.init.general/7] (bold emphasis mine):
To default-initialize an object of type
Tmeans:
- If
Tis a (possibly cv-qualified) class type ([class]), constructors are considered. The applicable constructors are enumerated ([over.match.ctor]), and the best one for the initializer()is chosen through overload resolution ([over.match]). The constructor thus selected is called, with an empty argument list, to initialize the object.- If
Tis an array type, each element is default-initialized.- Otherwise, no initialization is performed.