Movatterモバイル変換


[0]ホーム

URL:


Issue 178 - WG21 CWG Issues
Title
More on value-initialization
Status
tc1
Section
9.5 [dcl.init]
Submitter
Andrew Koenig

Created on1999-10-25.00:00:00 last changed277 months ago

Messages

msg241 (view)
Date: 2000-10-15.00:00:00

Proposed resolution (10/00):

[Note: this resolution supersedes the resolution toissue 35.]

In 7.6.1.4 [expr.type.conv] paragraph 2, replace "whose valueis determined by default-initialization" by "which isvalue-initialized".

In 7.6.2.8 [expr.new] paragraph 15,

  • In the first subitem of the first item, restore the missingperiod 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:

Tozero-initialize an object of typeT means:

  • ifT is a scalar type (6.9 [basic.types]), theobject is set to the value of 0 (zero) converted toT;
  • ifT is a non-union class type, each non-static datamember and each base-class subobject is zero-initialized;
  • ifT is a union type, the object's first named data member[Footnote: This member must not bestatic, by virtueof the requirements in 11.5 [class.union].endfootnote] is zero-initialized;
  • ifT is an array type, each element iszero-initialized;
  • ifT is a reference type, no initialization isperformed.

Todefault-initialize an object of typeT means:

  • ifT is a non-POD class type (Clause 11 [class]), the default constructor forT is called (and theinitialization is ill-formed ifT has no accessible defaultconstructor);
  • ifT is an array type, each element isdefault-initialized;
  • otherwise, the object is zero-initialized.

Tovalue-initialize an object of typeT means:

  • ifT is a class type (Clause 11 [class])with a user-declared constructor (11.4.5 [class.ctor]), thenthe default constructor forT is called (and theinitialization is ill-formed ifT has no accessible defaultconstructor);
  • ifT is a non-union class type without a user-declaredconstructor, then every non-static data member and base-classcomponent ofT is value-initialized;
  • ifT is an array type, then each element isvalue-initialized;
  • otherwise, the object is zero-initialized.

A program that calls for default-initialization of an entity ofreference type is ill-formed. IfT is a cv-qualified type,the cv-unqualified version ofT is used for these definitionsof zero-initialization, default-initialization, andvalue-initialization.

In 9.5 [dcl.init] paragraph 6, change "The memoryoccupied 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 "orvalue-initialization" after the first occurrence of"default-initialization".

In 11.9 [class.init] paragraph 1, replace the note by "Theobject is default-initialized if there is no initializer, orvalue-initialized if the initializer is()" [i.e., replacethe 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 bulleteditem.

In 11.9.3 [class.base.init] paragraph 4, replace"default-initialized, nor initialized" by "default-initialized, norvalue-initialized, nor assigned".

msg240 (view)
Date: 2003-04-25.00:00:00

When the Committee consideredissue 35, another context in whichvalue initialization might be relevant was overlooked:mem-initializers. It would seem reasonable that ifT() as an expression invokes value initialization, that thesame syntactic construct in amem-initializer-list would do thesame, and the usefulness of value initialization in that context is atleast as great as the standalone case.

History
DateUserActionArgs
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

[8]ページ先頭

©2009-2026 Movatter.jp