Movatterモバイル変換


[0]ホーム

URL:


Issue 1502 - WG21 CWG Issues
Title
Value initialization of unions with member initializers
Status
cd3
Section
9.5 [dcl.init]
Submitter
Richard Smith

Created on2012-05-06.00:00:00 last changed145 months ago

Messages

msg4407 (view)
Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

msg4063 (view)
Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

Change 9.5 [dcl.init] paragraph 7 as follows:

Tovalue-initialize an object of typeT means:

  • ...

  • ifT is a (possibly cv-qualified)non-unionclass type without a user-provided or deleted default constructor,then the object is zero-initialized and, ifT has anon-trivial default constructor, default-initialized;

  • ...

msg3950 (view)
Date: 2022-02-18.07:47:23

According to 9.5 [dcl.init] paragraph 7,

Tovalue-initialize an object of typeT means:

  • ifT is a (possibly cv-qualified) class type (Clause 11 [class]) with either no default constructor(11.4.5 [class.ctor]) or a default constructor that isuser-provided or deleted, then the object is default-initialized;

  • ifT is a (possibly cv-qualified) non-union class type without auser-provided or deleted default constructor, then the object iszero-initialized and, ifT has a non-trivial default constructor,default-initialized;

  • ifT is an array type, then each element is value-initialized;

  • otherwise, the object is zero-initialized.

In an example like

  union U { int a = 5; };  int main() { return U().a; }

this means that the value returned is0, because none of thefirst three bullets apply. Should the “non-union”restriction be dropped from the second bullet?

History
DateUserActionArgs
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: +msg4407
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetmessages: +msg4063
2012-11-03 00:00:00adminsetstatus: open -> ready
2012-05-06 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp