This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Moved to DR at the November, 2014 meeting.]
The requirements for a constant expression in 7.7 [expr.const] permit an lvalue-to-rvalue conversion on
a non-volatile glvalue of integral or enumeration type that refers to a non-volatile const object with a preceding initialization, initialized with a constant expression
This does not exclude subobjects of objects that are not compile-time constants, for example:
int f(); struct S { S() : a(f()), b(5) {} int a, b; }; const S s; constexpr int k = s.b;
This rule is intended to provide backward compatibility with pre-constexpr C++, but it should be restricted to complete objects. Care should be taken in resolving this issue not to break the handling of string literals, since use of their elements in constant expressions depends on the current form of this rule.
Proposed resolution (February, 2014):
Change 7.7 [expr.const] bullet 2.7 as follows:
A conditional-expression e is a core constant expression unless the evaluation of e, following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following expressions:
...
an lvalue-to-rvalue conversion (7.3.2 [conv.lval]) unless it is applied to
a non-volatile glvalue of integral or enumeration type that refers to a complete non-volatile const object with a preceding initialization, initialized with a constant expression
[Note: a string literal (5.13.5 [lex.string]) corresponds to an array of such objects. —end note], ora non-volatile glvalue that refers to a subobject of a string literal (5.13.5 [lex.string]), or
a non-volatile glvalue that refers to a non-volatile object defined with constexpr...