Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


1612. Implicit lambda capture and anonymous unions

Section:7.5.6.3  [expr.prim.lambda.capture]    Status:C++14    Submitter:Michael Wong    Date:2013-01-31

N3690 comment CA 17

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

It is not clear from the description of capturing in7.5.6 [expr.prim.lambda] whether an implicit capture resultingfrom the odr-use of a member of an anonymous union captures thatmember or the anonymous union, and there is implementationdivergence. 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 unionshould be ill-formed.

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 memberof 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 aredeclared in the closure type for entities captured byreference.A member of an anonymous union shall not be captured byreference. [Note:...



[8]ページ先頭

©2009-2026 Movatter.jp