Created on2015-02-11.00:00:00 last changed62 months ago
Proposed resolution (January, 2019):
Change 6.3 [basic.def.odr] bullet 2.4 as follows:
An expression ispotentially evaluated unless itis an unevaluated operand (7.2 [expr.prop]) or asubexpression thereof. The set ofpotential resultsof an expressione is defined as follows:
...
Ife is a pointer-to-member expression(7.6.4 [expr.mptr.oper])
whose second operand is aconstant expression, the set contains the potential resultsof the object expression....
Otherwise, the set is empty.
Change 6.3 [basic.def.odr] paragraph 4, converting therunning text into bullets, as follows:
A variablex whose name appears as apotentially-evaluated expressione
xis odr-usedbyexunlessapplying the lvalue-to-rvalueconversion (7.3.2 [conv.lval]) tox yieldsa constant expression (7.7 [expr.const]) that doesnot invoke a function other than a trivial special memberfunction (11.4.4 [special]) and, ifx isan object,
x is a reference that is usable inconstant expressions (7.7 [expr.const]), or
x is a variable of non-reference typethat is usable in constant expressions and has no mutablesubobjects, ande
xis an elementof the set of potential results of anexpressione, where eitherofnon-volatile-qualified non-class type to which thelvalue-to-rvalue conversion (7.3.2 [conv.lval]) isappliedtoe, ore isx is a variable of non-reference type, ande is an element of the set of potential results ofa discarded-value expression (7.2 [expr.prop])to which the lvalue-to-rvalue conversion is notapplied.
[Accepted as a DR at the February, 2019 meeting.]
The resolution ofissue 1741 was notintended to cause odr-use to occur in cases where it did not do sopreviously. 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 aconstant expression, but applying the lvalue-to-rvalueconverstion tox 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 constantexpression, but applying the lvalue-to-rvalue conversion toainvokes a non-trivial function.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2020-12-15 00:00:00 | admin | set | messages: +msg6347 |
| 2020-12-15 00:00:00 | admin | set | status: drafting -> cd5 |
| 2017-02-06 00:00:00 | admin | set | status: open -> drafting |
| 2015-02-11 00:00:00 | admin | create | |