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

2024-11-11


1927. Lifetime of temporaries in init-captures

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: dup     Submitter: Daveed Vandevoorde     Date: 2014-05-14

The current Standard is not clear regarding the lifetime of a temporary created in the initializer of an init-capture:

  void g() {
    struct S { S(int); ~S(); };
    auto x = (S(1), [y = S(2)]{}, S(3));
  }

Is the initializer for y considered a full-expression, or does the S(2) temporary persist until the end of the complete x initializer?

Reationale (June, 2014):

This issue is a duplicate of issue 1695.