This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Moved to DR at the April, 2013 meeting.]
We have a special case in 6.3 [basic.def.odr] paragraph 2 thatvariables which satisfy the requirements for appearing in a constantexpression are not odr-used if the lvalue-to-rvalue conversion isimmediately applied. This special case only applies to objects, andthus does not apply to variables of reference type. Thisinconsistency seems strange, and there is implementation divergence:
int n; void f() { constexpr int &r = n; [] { return r; }; // error:r is odr-used but not captured }This code is accepted by g++ but rejected by clang. Shouldr beodr-used here?
Proposed resolution (October, 2012):
Change 6.3 [basic.def.odr] paragraph 3 as follows:
A variablex whose name appears as a potentially-evaluatedexpressionex isodr-used unlessxis anobject thatsatisfies the requirements for appearing in aconstant expression (7.7 [expr.const]) and, ifx is an object,ex is an element of the set ofpotential results of an expressione, where either thelvalue-to-rvalue conversion (7.3.2 [conv.lval]) is applied toe, ore is a discarded-value expression (Clause 7 [expr]).this is odr-used...