Title
Missing requirements for constexpr constructors
Status
c++11
Section
9.2.6 [dcl.constexpr]
Submitter
Alisdair Meredith

Created on 2009-05-08.00:00:00 last changed 96 months ago

Messages

Date: 2010-08-23.00:00:00

[Voted into WP at August, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

Change 9.2.6 [dcl.constexpr] paragraph 4 as follows:

The definition of a constexpr constructor shall satisfy the following constraints:

  • each of its parameter types shall be a literal type or a reference to a literal type

  • its function-body shall not be a function-try-block

  • the compound-statement of its function-body shall be empty

  • every non-static data member and base class sub-object shall be initialized (11.9.3 [class.base.init])

  • every constructor involved in initializing non-static data members and base class sub-objects invoked by a mem-initializer shall be a constexpr constructor.

  • every constructor argument and full-expression in a mem-initializer shall be a potential constant expression

  • every assignment-expression that is an initializer-clause appearing directly or indirectly within a brace-or-equal-initializer for a non-static data member that is not named by a mem-initializer-id shall be a constant expression

  • every implicit conversion used in converting a constructor argument to the corresponding parameter type and converting a full-expression to the corresponding member type shall be one of those allowed in a constant expression.

Date: 2009-05-08.00:00:00

The rules for constexpr constructors are missing some necessary requirements. In particular, there is no requirement that a brace-or-equal-initializer for a non-static data member be a constant expression, and the requirement for constexpr constructors for initializing non-static data members applies only to members named in a mem-initializer, allowing a non-constexpr default constructor to be invoked.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: wp -> fdis
2010-11-29 00:00:00adminsetstatus: dr -> wp
2010-08-23 00:00:00adminsetmessages: + msg2913
2010-08-23 00:00:00adminsetstatus: ready -> dr
2010-03-29 00:00:00adminsetstatus: review -> ready
2010-02-16 00:00:00adminsetmessages: + msg2535
2010-02-16 00:00:00adminsetstatus: drafting -> review
2009-08-03 00:00:00adminsetstatus: open -> drafting
2009-05-08 00:00:00admincreate