Created on 2017-11-01.00:00:00 last changed 47 months ago
Proposed resolution, June, 2019:
Change 6.9.3.2 [basic.start.static] paragraph 2 as follows:
Constant initialization is performed if a variable or temporary object with static or thread storage duration is constant-initializedby a constant initializer(7.7 [expr.const])for the entity. If constant initialization is not performed, a variable with static storage duration (6.7.5.2 [basic.stc.static]) or thread storage duration (6.7.5.3 [basic.stc.thread]) is zero-initialized (9.4 [dcl.init]). Together, zero-initialization and constant initialization...
Change 7.7 [expr.const] paragraph 2 as follows:
A
constant initializer for avariable or temporary object o isan initializer for which interpreting its full-expression as a constant-expression results in a constant expressionconstant-initialized if
either it has an initializer or its default-initialization results in some initialization being performed, and
its initialization full-expression is a constant expression when interpreted as a constant-expression, except that if o is an object,
such an initializerthe initialization full-expression 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. Within this evaluation, std::is_constant_evaluated() (21.3.11 [meta.const.eval]) returns true. —end note]
Change 7.7 [expr.const] paragraph 3 as follows:
A variable is usable in constant expressions after its initializing declaration is encountered if it is a constexpr variable, or it is a constant-initialized variable of reference type or of const-qualified integral or enumeration type, and its initializer is a constant initializer.
Change 9.2.6 [dcl.constexpr] paragraph 5 as follows:
For a constexpr function or constexpr constructor that is neither defaulted nor a template, if no argument values exist such that an invocation of the function or constructor could be an evaluated subexpression of a core constant expression (7.7 [expr.const]), or, for a constructor,a constant initializer foran evaluated subexpression of the initialization full-expression of some constant-initialized object (6.9.3.2 [basic.start.static]), the program is ill-formed, no diagnostic required. [Example:...
Notes from the October, 2018 teleconference:
CWG agreed that the example should be well-formed.
[Accepted as a DR at the July, 2019 meeting.]
According to 6.9.3.2 [basic.start.static] paragraph 2,
Constant initialization is performed if a variable or temporary object with static or thread storage duration is initialized by a constant initializer for the entity. If constant initialization is not performed, a variable with static storage duration (6.7.5.2 [basic.stc.static]) or thread storage duration (6.7.5.3 [basic.stc.thread]) is zero-initialized (9.4 [dcl.init]). Together, zero-initialization and constant initialization are called static initialization; all other initialization is dynamic initialization.
This appears to require an explicit initializer for constant initialization and would preclude examples like:
struct S { int i = 1; }; static constexpr S s;
where there is no initializer.
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-12-15 00:00:00 | admin | set | messages: + msg6369 |
2020-12-15 00:00:00 | admin | set | messages: + msg6368 |
2017-11-01 00:00:00 | admin | create |