- Title
- odr-use of reference variables
- Status
- cd3
- Section
- 6.3 [basic.def.odr]
- Submitter
- Richard Smith
Created on 2012-03-01.00:00:00 last changed 152 months ago
Messages
Date: 2013-04-15.00:00:00
[Moved to DR at the April, 2013 meeting.]
Date: 2012-10-15.00:00:00
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 x
is an
object that satisfies 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...
Date: 2026-07-27.15:54:01
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:
This code is accepted by g++ but rejected by clang. Should r be
odr-used here?
int n;
void f() {
constexpr int &r = n;
[] { return r; }; // error: r is odr-used but not captured
}
| 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 | |