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

2026-03-27


3156. Handling of deleted functions in unevaluated lambda-captures

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: ready     Submitter: Anoop S. Rana     Date: 2026-01-29

(From submission #841.)

Consider:

  struct C
  {
    C(int) = delete;
    C(){};
  };

  decltype([b = C(3)](){ return 4; }()) x; //MSVC accepts; gcc and clang reject

Arguably, 7.5.6.3 [expr.prim.lambda.capture] paragraph 15 specifies that the initialization of the non-static data members only happens when the lambda-expression is evaluated, but there is no statement when the semantic contraints of such an initialization are checked.

Proposed resolution (approved by CWG 2026-03-27):

Change in 7.5.6.3 [expr.prim.lambda.capture] paragraph 15 as follows:

When the lambda-expression is evaluated, the The entities that are captured by copy are used to direct-initialize each corresponding non-static data member of the resulting closure object, and the non-static data members corresponding to the init-captures are initialized as indicated by the corresponding initializer (which may be copy- or direct-initialization). (For array members, the array elements are direct-initialized in increasing subscript order.) These initializations are performed when the lambda-expression is evaluated and in the (unspecified) order in which the non-static data members are declared.