Created on 2008-03-13.00:00:00 last changed 33 months ago
[Voted into the WP at the September, 2008 meeting (resolution in paper N2757).]
Proposed resolution (June, 2008):
Change 6.9.3.2 [basic.start.static] paragraph 1 as follows:
Objects with static storage duration (6.7.5.2 [basic.stc.static]) or thread storage duration (3.7.2) shall be zero-initialized (9.4 [dcl.init]) before any other initialization takes place.A reference with static or thread storage duration and an object of trivial or literal type with static or thread storage duration can be initialized with a constant expression (7.7 [expr.const]); this is called constant initialization.Constant initialization is performed:Together, zero-initialization and constant initialization...
if an object of trivial or literal type with static or thread storage duration is initialized with a constant expression (7.7 [expr.const]), or
if a reference with static or thread storage duration is initialized with a constant expression that is not an lvalue designating an object with thread or automatic storage duration.
Add the following in 7.7 [expr.const] paragraph 2:
an lvalue-to-rvalue conversion (4.1) unless it is applied to...
an array-to-pointer conversion (7.3.3 [conv.array]) that is applied to an lvalue that designates an object with thread or automatic storage duration
a unary operator & (7.6.2.2 [expr.unary.op]) that is applied to an lvalue that designates an object with thread or automatic storage duration
an id-expression that refers to a variable or data member of reference type;
...
(Note: the change to 6.9.3.2 [basic.start.static] paragraph 1 needs to be reconciled with the conflicting change in issue 688.)
Suggested resolution:
Add the following bullet to the list in 7.7 [expr.const] paragraph 2:
an id-expression that refers to a variable with automatic storage duration unless a permitted lvalue-to-rvalue conversion is applied (see above)
The expressions that are excluded from being constant expressions in 7.7 [expr.const] paragraph 2 does not address an example like the following:
void f() {
int a;
constexpr int* p = &a; // should be ill-formed, currently isn't
}
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-02-18 07:47:23 | admin | set | messages: + msg6699 |
2008-10-05 00:00:00 | admin | set | messages: + msg1816 |
2008-10-05 00:00:00 | admin | set | status: review -> cd1 |
2008-06-29 00:00:00 | admin | set | messages: + msg1693 |
2008-06-29 00:00:00 | admin | set | status: open -> review |
2008-03-13 00:00:00 | admin | create |