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
[Moved to DR at the February, 2014 meeting.]
It is not clear from the description of capturing in 7.5.6 [expr.prim.lambda] whether an implicit capture resulting from the odr-use of a member of an anonymous union captures that member or the anonymous union, and there is implementation divergence. For example,
int main() { static int result; struct A { int x; }; struct B { int y; }; union { A a; B b; }; a.x = 1; [=]() mutable { a.x = 2; result = b.y; }(); if (result == 1) return 0; throw 0; }
Notes from the April, 2013 meeting:
CWG decided that an attempt to capture a member of an anonymous union should be ill-formed.
Proposed resolution (September, 2013):
Change 7.5.6 [expr.prim.lambda] paragraph 15 as follows:
...An array of runtime bound (9.3.4.5 [dcl.array]) or a member of an anonymous union shall not be captured by copy.
Change 7.5.6 [expr.prim.lambda] paragraph 16 as follows:
...It is unspecified whether additional unnamed non-static data members are declared in the closure type for entities captured by reference. A member of an anonymous union shall not be captured by reference. [Note:...