1 // Test that we properly extend the lifetime of the initializer_list
2 // array even if the initializer_list is a subobject.
3 // { dg-do run { target c++11 } }
5 #include <initializer_list>
7 extern "C" void abort();
13 A(int) { if (do_throw) throw 42; }
14 ~A() { if (!ok) abort(); }
17 typedef std::initializer_list<A> AL;
18 typedef std::initializer_list<AL> AL2;
19 typedef std::initializer_list<AL2> AL3;
48 AL ar[2] = {{1,2},{3,4}};
50 AL3 al3 = {{{1},{2},{3}}};
52 A2 a2r[2] = {{1,2},{3,4}};
56 int main(int argc, const char** argv)
58 do_throw = (argc > 1); // always false, but optimizer can't tell