Created on 2013-08-21.00:00:00 last changed 133 months ago
[Moved to DR at the February, 2014 meeting.]
Proposed resolution (September, 2013):
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 unlessx satisfies the requirements for appearing in a constant expression (7.7 [expr.const])applying the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) to x yields a constant expression (7.7 [expr.const]) that does not invoke any non-trivial functions 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...
According to 7.3.2 [conv.lval] paragraph 2,
if the glvalue has a class type, the [lvalue-to-rvalue] conversion copy-initializes a temporary of type T from the glvalue and the result of the conversion is a prvalue for the temporary.
The implications of such a conversion for odr-use do not appear to have been factored into 6.3 [basic.def.odr] paragraph 3, which exempts constant objects that are immediately lvalue-to-rvalue converted. For example, given
struct S { int n; };
struct T {
static constexpr S s = {};
};
void f(...);
void g() { f(T::s); }
Does this odr-use T::s, requiring it to have a definition, because of binding it to the reference parameter of S's copy constructor? How about
struct S { int n; };
void f(...);
void g() {
constexpr S s = {};
[] { f(s); };
}
Does s need to be captured? There is implementation variance on both these examples.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-11-24 00:00:00 | admin | set | status: dr -> c++14 |
| 2014-03-03 00:00:00 | admin | set | messages: + msg4927 |
| 2014-03-03 00:00:00 | admin | set | status: ready -> dr |
| 2013-10-14 00:00:00 | admin | set | messages: + msg4566 |
| 2013-10-14 00:00:00 | admin | set | status: open -> ready |
| 2013-08-21 00:00:00 | admin | create | |