Created on 2012-03-17.00:00:00 last changed 131 months ago
Proposed resolution (April, 2013):
This issue was rendered moot by paper N3652, adopted at the April, 2013 meeting.
Additional note (February, 2013):
The intent is that non-const references to temporaries should be allowed within constant expressions, e.g., across constexpr function calls, but not as the result of a constant expression.
The following initializations appear to be well-formed:
struct C { int m; constexpr C(int m ) : m{m} {}; constexpr int get() { return m; }; }; C&& rr = C{1}; constexpr int k1 = rr.get(); const C& cl = C{1}; constexpr int k2 = cl.get();
They appear to fall under the bullet of 7.7 [expr.const] paragraph 2,
an lvalue-to-rvalue conversion (7.3.2 [conv.lval]) unless it is applied to
...
a non-volatile glvalue of literal type that refers to a non-volatile temporary object whose lifetime has not ended, initialized with a constant expression;
The problem in this example is that the referenced temporary object is not a constant, so it would be well-defined for intervening code to modify its value before it was used in the later initialization.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: wp -> cd3 |
2014-01-20 00:00:00 | admin | set | messages: + msg4791 |
2014-01-20 00:00:00 | admin | set | status: drafting -> wp |
2013-03-18 00:00:00 | admin | set | messages: + msg4256 |
2012-11-03 00:00:00 | admin | set | status: open -> drafting |
2012-03-17 00:00:00 | admin | create |