Title
constexpr initialization requirements for variant members
Status
c++20
Section
9.2.6 [dcl.constexpr]
Submitter
Richard Smith

Created on 2019-08-03.00:00:00 last changed 7 months ago

Messages

Date: 2019-09-15.00:00:00

Proposed resolution (September, 2019):

Delete the indcated text from 9.2.6 [dcl.constexpr] paragraph 4:

The definition of a constexpr constructor whose function-body is not = delete shall additionally satisfy the following requirements:

  • if the class is a union having variant members (11.5 [class.union]), exactly one of them shall be initialized;

  • if the class is a union-like class, but is not a union, for each of its anonymous union members having variant members, exactly one of them shall be initialized;

  • for a non-delegating constructor, every constructor selected to initialize non-static data members and base class subobjects shall be a constexpr constructor;

  • for a delegating constructor, the target constructor shall be a constexpr constructor.

Date: 2019-11-15.00:00:00

[Adopted as a DR at the November, 2019 meeting.]

Paper P1331R2 removed the requirement that a constexpr constructor initialize every non-variant non-static data member, but it left untouched the corresponding requirements for variant members. That is, the modified text in 9.2.6 [dcl.constexpr] paragraph 4 still contains:

The definition of a constexpr constructor whose function-body is not = delete shall additionally satisfy the following requirements:

  • if the class is a union having variant members (11.5 [class.union]), exactly one of them shall be initialized;

  • if the class is a union-like class, but is not a union, for each of its anonymous union members having variant members, exactly one of them shall be initialized;

Presumably this was an oversight and these two bullets should be changed from “exactly” to “at most” or something similar.

History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6452
2019-08-03 00:00:00admincreate