This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Moved to DR at the November, 2014 meeting.]
We're missing a restriction on the value of a temporary which is bound to a static storage duration reference:
void f(int n) { static constexpr int *&&r = &n; }
This is currently valid, because &n is a core constant expression, and it is a constant expression because the reference binds to a temporary (of type int*) that has static storage duration (because it's lifetime-extended by the reference binding).
The value of r is constant here (it's a constant reference to a temporary with a non-constant initializer), but I don't think we should accept this. Generally, I think a temporary which is lifetime-extended by a constexpr variable should also be treated as if it were declared to be a constexpr object.
Proposed resolution (September, 2013) [SUPERSEDED]:
Change 7.7 [expr.const] paragraph 4 as follows:
A constant expression is either a glvalue core constant expression whose value refers to an
object with static storage duration or to a functionentity that is a permitted result of a constant expression, or a prvalue core constant expression whose value is an object where, for that object and its subobjects:
each non-static data member of reference type refers to an
object with static storage duration or to a functionentity that is a permitted result of a constant expression, andif the object or subobject is of pointer type, it contains the address of an object with static storage duration, the address past the end of such an object (7.6.6 [expr.add]), the address of a function, or a null pointer value.
An entity is a permitted result of a constant expression if it is an object with static storage duration that is either not a temporary or is a temporary whose value satisfies the above constraints, or it is a function.
Proposed resolution (February, 2014):
Change 7.7 [expr.const] paragraph 4 as follows:
A constant expression is either a glvalue core constant expression whose value refers to an
object with static storage duration or to a functionentity that is a permitted result of a constant expression (as defined below), or a prvalue core constant expression whose value is an object where, for that object and its subobjects:
each non-static data member of reference type refers to an
object with static storage duration or to a functionentity that is a permitted result of a constant expression, andif the object or subobject is of pointer type, it contains the address of an object with static storage duration, the address past the end of such an object (5.7), the address of a function, or a null pointer value.
An entity is a permitted result of a constant expression if it is an object with static storage duration that is either not a temporary object or is a temporary object whose value satisfies the above constraints, or it is a function.