Title
Implicit lambda capture and anonymous unions
Status
c++14
Section
7.5.6.3 [expr.prim.lambda.capture]
Submitter
Michael Wong

Created on 2013-01-31.00:00:00 last changed 121 months ago

Messages

Date: 2014-02-15.00:00:00

[Moved to DR at the February, 2014 meeting.]

Date: 2013-09-15.00:00:00

Proposed resolution (September, 2013):

  1. Change 7.5.6 [expr.prim.lambda] paragraph 15 as follows:

  2. ...An array of runtime bound (9.3.4.5 [dcl.array]) or a member of an anonymous union shall not be captured by copy.
  3. Change 7.5.6 [expr.prim.lambda] paragraph 16 as follows:

  4. ...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:...
Date: 2013-04-15.00:00:00

Notes from the April, 2013 meeting:

CWG decided that an attempt to capture a member of an anonymous union should be ill-formed.

Date: 2013-10-14.00:00:00
N3690 comment CA 17

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;
  }
History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: dr -> c++14
2014-03-03 00:00:00adminsetmessages: + msg4936
2014-03-03 00:00:00adminsetstatus: ready -> dr
2013-10-14 00:00:00adminsetmessages: + msg4573
2013-10-14 00:00:00adminsetstatus: drafting -> ready
2013-05-03 00:00:00adminsetmessages: + msg4330
2013-05-03 00:00:00adminsetstatus: open -> drafting
2013-01-31 00:00:00admincreate