http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57745
Bug ID: 57745 Summary: missing recursive lifetime extension within std::initializer_list Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: richard-gccbugzilla at metafoo dot co.uk Consider: #include <iostream> struct A { A() { std::cout << " A()" << std::endl; } ~A() { std::cout << "~A()" << std::endl; } }; struct B { const A &a; ~B() { std::cout << "~B()" << std::endl; } }; struct C { std::initializer_list<B> b; ~C() { std::cout << "~C()" << std::endl; } }; int main() { const C &c = C{ { { A() }, { A() } } }; std::cout << "-----" << std::endl; } This should print: A() A() ----- ~C() ~B() ~A() ~B() ~A() ... but g++ destroys the two A temporaries at the end of the full-expression. They are lifetime-extended because they are bound to B::a references in the aggregate-initialization of the B subobjects of the underlying array of the initializer_list, which is itself lifetime-extended.