Title
More on value-initialization
Status
tc1
Section
9.4 [dcl.init]
Submitter
Andrew Koenig

Created on 1999-10-25.00:00:00 last changed 255 months ago

Messages

Date: 2000-10-15.00:00:00

Proposed resolution (10/00):

[Note: this resolution supersedes the resolution to issue 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.4 [dcl.init])".

Replace 9.4 [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.4 [dcl.init] paragraph 6, change "The memory occupied by any" to "Every".

In 9.4 [dcl.init] paragraph 7, replace "default-initialized" by "value-initialized".

In 9.4.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".

Date: 2003-04-25.00:00:00

When the Committee considered issue 35, another context in which value initialization might be relevant was overlooked: mem-initializers. It would seem reasonable that if T() 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.

History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: review -> dr
2000-05-21 00:00:00adminsetstatus: drafting -> review
2000-02-23 00:00:00adminsetmessages: + msg241
1999-10-25 00:00:00admincreate