Title
Implicit default constructor definitions and const variant members
Status
cd2
Section
11.4.5 [class.ctor]
Submitter
Daveed Vandevoorde

Created on 2009-06-19.00:00:00 last changed 179 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-11-15.00:00:00

Proposed resolution (November, 2009):

Change 11.4.5 [class.ctor] bullet 5.3 of the second list and add two bullets as follows:

  • ...

  • any non-variant non-static data member of const-qualified type (or array thereof) does not have a user-provided default constructor, or

  • X is a union and all its variant members are of const-qualified type (or array thereof),

  • X is a non-union class and all members of any anonymous union member are of const-qualified type (or array thereof), or

  • ...

Date: 2009-10-15.00:00:00

Proposed resolution (October, 2009):

Change 11.4.5 [class.ctor] bullet 5.3 of the second list and add a fourth bullet as follows:

  • ...

  • any non-variant non-static data member of const-qualified type (or array thereof) does not have a user-provided default constructor, or

  • all variant members are of const-qualified type (or array thereof), or

  • ...

Date: 2009-06-19.00:00:00

According to 11.4.5 [class.ctor] paragraph 5,

An implicitly-declared default constructor for class X is defined as deleted if: ... any non-static data member of const-qualified type (or array thereof) does not have a user-provided default constructor, or...

It is not clear if this adequately covers the case in which some variant members are const-qualified but others are not. The intent of the restriction is to prevent creation of an object with uninitialized members that would require a const_cast to set their value later, but const-qualified members of an anonymous union in which other members are not const do not seem to present that problem.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2717
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2504
2010-02-16 00:00:00adminsetstatus: review -> tentatively ready
2009-11-08 00:00:00adminsetmessages: + msg2381
2009-11-08 00:00:00adminsetstatus: open -> review
2009-06-19 00:00:00admincreate