Title
Constant initialization via aggregate initialization
Status
c++17
Section
6.9.3.2 [basic.start.static]
Submitter
Daniel Krügler

Created on 2013-05-05.00:00:00 last changed 81 months ago

Messages

Date: 2017-11-15.00:00:00

Proposed resolution (November, 2016):

  1. Change 6.9.3.2 [basic.start.static] paragraph 2 as follows, converting the bulleted list into running text as indicated:

  2. A constant initializer for an a variable or temporary object o is an expression that initializer whose full-expression is a constant expression, except that it if o is an object, such an initializer may also invoke constexpr constructors for o and its subobjects even if those objects are of non-literal class types. [Note: Such a class may have a non-trivial destructor —end note] Constant initialization is performed:

    • if each full-expression (including implicit conversions) that appears in the initializer of a reference with static or thread storage duration is a constant expression (7.7 [expr.const]) and the reference is bound to a glvalue designating an object with static storage duration, to a temporary object (see 6.7.7 [class.temporary]) or subobject thereof, or to a function;

    • if an a variable or temporary object with static or thread storage duration is initialized by a constructor call, and if the initialization full-expression is a constant initializer for the object; entity

    • if an object with static or thread storage duration is not initialized by a constructor call and if either the object is value-initialized or every full-expression that appears in its initializer is a constant expression.

    If constant initialization is not performed...

  3. Change 7.7 [expr.const] paragraph 2 as follows:

    A conditional-expression An expression e is a core constant expression unless...
Date: 2017-02-15.00:00:00

[Adopted at the February/March, 2017 meeting.]

The resolution of issue 1489 added wording regarding value initialization to 6.9.3.2 [basic.start.static] paragraph 2 in an attempt to clarify the status of an example like

  int a[1000]{};

However, this example is aggregate initialization, not value initialization. Also, now that we allow brace-or-equal-initializers in aggregates, this wording also needs to be updated to allow an aggregate with constant non-static data member initializers to qualify for constant initialization.

History
Date User Action Args
2018-02-27 00:00:00adminsetstatus: ready -> c++17
2017-02-06 00:00:00adminsetmessages: + msg5714
2017-02-06 00:00:00adminsetstatus: drafting -> ready
2013-10-14 00:00:00adminsetstatus: open -> drafting
2013-05-05 00:00:00admincreate