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


753. Array names in lambda capture sets

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: CD2     Submitter: Daveed Vandevoorde     Date: 10 December, 2008

[Voted into the WP at the July, 2009 meeting as part of N2927.]

The current specification does not adequately describe what happens when an array name is part of the effective capture set of a lambda expression. 7.5.6 [expr.prim.lambda] paragraph 13 says that the array member of the closure object is direct-initialized by the local array; however, 9.4 [dcl.init] paragraph 16 says that such an initialization is ill-formed. There are several possibilities for handling this problem:

  1. This results in an array member of the closure object, which is initialized by copying each element, along the lines of 11.4.5.3 [class.copy.ctor] paragraph 8.

  2. This results in a pointer member of the closure object, initialized to point to the first element of the array (i.e., the array lvalue decays to a pointer rvalue).

  3. This is ill-formed.

  4. This results in a reference-to-array member of the closure object, initialized to refer to the array, regardless of whether & was used or not.

  5. This is ill-formed unless the capture is “by reference.”

Proposed resolution (July, 2009)

See document PL22.16/09-0117 = WG21 N2927.