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


1565. Copy elision and lifetime of initializer_list underlying array

Section: 9.4.5  [dcl.init.list]     Status: NAD     Submitter: Steve Adamczyk     Date: 2012-10-10

If an initializer_list object is copied and the copy is elided, is the lifetime of the underlying array object extended? E.g.,

  void f() {
    std::initializer_list<int> L =
        std::initializer_list<int>{1, 2, 3}; // Lifetime of array extended?
  }

The current wording is not clear.

(See also issue 1299.)

Notes from the October, 2012 meeting:

The consensus of CWG was that the behavior should be the same, regardless of whether the copy is elided or not.

Rationale (November, 2016):

With the adoption of paper P0135R1, there is no longer any copy in this example to be elided.