*This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
Core Issues List revision 114a.
See http://www.open-std.org/jtc1/sc22/wg21/ for the official
list.*

2024-04-18

[Accepted as a DR at the February, 2019 meeting.]

The resolution of issue 1741 was not intended to cause odr-use to occur in cases where it did not do so previously. However, in an example like

extern int globx; int main() { const int &x = globx; struct A { const int *foo() { return &x; } } a; return *a.foo(); }

`x` satisfies the requirements for appearing in a
constant expression, but applying the lvalue-to-rvalue
converstion to `x` does not yield a constant expression.
Similarly,

struct A { int q; constexpr A(int q) : q(q) { } constexpr A(const A &a) : q(a.q * 2) { } }; int main(void) { constexpr A a(42); constexpr int aq = a.q; struct Q { int foo() { return a.q; } } q; return q.foo(); }

`a` satisfies the requirements for appearing in a constant
expression, but applying the lvalue-to-rvalue conversion to `a`
invokes a non-trivial function.

**Proposed resolution (January, 2019):**

Change 6.3 [basic.def.odr] bullet 2.4 as follows:

...

If

`e`is a pointer-to-member expression (7.6.4 [expr.mptr.oper])~~whose second operand is a constant expression~~, the set contains the potential results of the object expression....

Otherwise, the set is empty.

Change 6.3 [basic.def.odr] paragraph 4, converting the running text into bullets, as follows:

`x`is a reference that is usable in constant expressions (7.7 [expr.const]), or`x`is a variable of non-reference type that is usable in constant expressions and has no mutable subobjects, and`e`is an element of the set of potential results of an expression~~x~~of non-volatile-qualified non-class type to which the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) is applied`e`, where either~~to~~, or`e``e`is`x`is a variable of non-reference type, and`e`is an element of the set of potential results of a discarded-value expression (7.2 [expr.prop]) to which the lvalue-to-rvalue conversion is not applied.

An expression is

potentially evaluatedunless it is an unevaluated operand (7.2 [expr.prop]) or a subexpression thereof. The set ofpotential resultsof an expressioneis defined as follows:

A variable

xwhose name appears as a potentially-evaluated expressioneis odr-used by~~x~~eunless~~x~~~~applying the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) to~~xyields a constant expression (7.7 [expr.const]) that does not invoke a function other than a trivial special member function (11.4.4 [special]) and, ifxis an object,