CWG Issue 178 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-04-13
178. More on value-initialization
Section: 9.5 [dcl.init]Status: TC1Submitter: Andrew KoenigDate: 25 Oct 1999
When the Committee consideredissue 35, another context in which value initialization might be relevant was overlooked:_mem-initializer_s. It would seem reasonable that ifT() as an expression invokes value initialization, that the same syntactic construct in a mem-initializer-list would do the same, and the usefulness of value initialization in that context is at least as great as the standalone case.
Proposed resolution (10/00):
[Note: this resolution supersedes the resolution toissue 35.]
In 7.6.1.4 [expr.type.conv] paragraph 2, replace "whose value is determined by default-initialization" by "which is value-initialized".
In 7.6.2.8 [expr.new] paragraph 15,
- In the first subitem of the first item, restore the missing period at the end of the first sentence.
- In the second item, replace the text after the comma by "the item is value-initialized (9.5 [dcl.init])".
Replace 9.5 [dcl.init] paragraph 5 by:
To zero-initialize an object of type T means:
- if T is a scalar type (6.8 [basic.types]), the object is set to the value of 0 (zero) converted to T;
- if T is a non-union class type, each non-static data member and each base-class subobject is zero-initialized;
- if T is a union type, the object's first named data member [_Footnote:_ This member must not be static, by virtue of the requirements in 11.5 [class.union]. _end footnote_] is zero-initialized;
- if T is an array type, each element is zero-initialized;
- if T is a reference type, no initialization is performed.
To default-initialize an object of type T means:
- if T is a non-POD class type (Clause 11 [class]), the default constructor for T is called (and the initialization is ill-formed if T has no accessible default constructor);
- if T is an array type, each element is default-initialized;
- otherwise, the object is zero-initialized.
To value-initialize an object of type T means:
- if T is a class type (Clause 11 [class]) with a user-declared constructor (11.4.5 [class.ctor]), 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 object is zero-initialized.
A program that calls for default-initialization of an entity of reference type is ill-formed. If T is a cv-qualified type, the cv-unqualified version of T is used for these definitions of zero-initialization, default-initialization, and value-initialization.
In 9.5 [dcl.init] paragraph 6, change "The memory occupied by any" to "Every".
In 9.5 [dcl.init] paragraph 7, replace "default-initialized" by "value-initialized".
In 9.5.2 [dcl.init.aggr] paragraph 7, replace "default-initialized" by "value-initialized".
In 11.4.8.2 [class.conv.ctor] paragraph 2, insert "or value-initialization" after the first occurrence of "default-initialization".
In 11.9 [class.init] paragraph 1, replace the note by "The object is default-initialized if there is no initializer, or value-initialized if the initializer is ()" [i.e., replace the non-normative note by different, normative text].
In 11.9.2 [class.expl.init] paragraph 2, replace "default-initialized" by "value-initialized".
In 11.9.3 [class.base.init] paragraph 3, replace "default-initialized" by "value-initialized" in the first bulleted item.
In 11.9.3 [class.base.init] paragraph 4, replace "default-initialized, nor initialized" by "default-initialized, nor value-initialized, nor assigned".