This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
Whether a reference is odr-used or not has less to do with the context where it is named and more to do with its initializer. In particular, 7.5.6 [expr.prim.lambda] bullet 12.2 leads to cases where references that can never be odr-used are implicitly captured:
A lambda-expression with an associated capture-default that does not explicitly capture this or a variable with automatic storage duration (this excludes any id-expression that has been found to refer to an init-capture's associated non-static data member), is said to implicitly capture the entity (i.e., this or a variable) if the compound-statement:
odr-uses (6.3 [basic.def.odr]) the entity, or
names the entity in a potentially-evaluated expression (6.3 [basic.def.odr]) where the enclosing full-expression depends on a generic lambda parameter declared within the reaching scope of the lambda-expression.
For example, ref should not be captured in the following:
struct A { A() = default; A(const A &) = delete; } globalA; constexpr bool bar(int &, const A &a) { return &a == &globalA; } int main() { A &ref = globalA; [=](auto q) { static_assert(bar(q, ref), ""); }(0); }