Created on 2012-03-01.00:00:00 last changed 130 months ago
[Moved to DR at the April, 2013 meeting.]
Proposed resolution (October, 2012):
Change 6.3 [basic.def.odr] paragraph 3 as follows:
A variable x whose name appears as a potentially-evaluated expression ex is odr-used unless xis an object thatsatisfies the requirements for appearing in a constant expression (7.7 [expr.const]) and, if x is an object, ex is an element of the set of potential results of an expression e, where either the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) is applied to e, or e is a discarded-value expression ( Clause 7 [expr]). this is odr-used...
We have a special case in 6.3 [basic.def.odr] paragraph 2 that variables which satisfy the requirements for appearing in a constant expression are not odr-used if the lvalue-to-rvalue conversion is immediately applied. This special case only applies to objects, and thus does not apply to variables of reference type. This inconsistency 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. Should r be odr-used here?
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: drwp -> cd3 |
2013-10-14 00:00:00 | admin | set | status: dr -> drwp |
2013-05-03 00:00:00 | admin | set | messages: + msg4367 |
2013-05-03 00:00:00 | admin | set | status: ready -> dr |
2012-11-03 00:00:00 | admin | set | messages: + msg4042 |
2012-11-03 00:00:00 | admin | set | status: open -> ready |
2012-03-01 00:00:00 | admin | create |