Created on 2017-11-10.00:00:00 last changed 46 months ago
Rationale (February, 2021):
The resolution of issue 2300 makes clear that this example is an ODR violation.
Notes from the October, 2018 teleconference:
This will be addressed by work already underway to rework the relationship between lambdas and the ODR.According to 6.3 [basic.def.odr] bullet 6.5,
in each definition of D, a default argument used by an (implicit or explicit) function call is treated as if its token sequence were present in the definition of D; that is, the default argument is subject to the requirements described in this paragraph (and, if the default argument has subexpressions with default arguments, this requirement applies recursively)
However, this rule is insufficient to handle a case like:
struct A { template<typename T> A(T); }; void f(A a = []{}); inline void g() { f(); }
This should be an ODR violation, because the call to f() will invoke a different specialization of the constructor template in each translation unit, but it is not, because the rule says this example is equivalent to:
inline void g() { f([]{}); }
which is not an ODR violation, since the type of the closure object will be the same in every translation unit (9.2.8 [dcl.inline] paragraph 6) ..
History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-17 00:00:00 | admin | set | messages: + msg6500 |
2021-02-17 00:00:00 | admin | set | status: open -> nad |
2020-12-15 00:00:00 | admin | set | messages: + msg6257 |
2017-11-10 00:00:00 | admin | create |