This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115g. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-16
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.
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.
Proposed resolution (April, 2013):
This issue was rendered moot by paper N3652, adopted at the April, 2013 meeting.