Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/initlist90.C

raw
1 // PR c++/57510
2 // { dg-do run { target c++11 } }
3
4 #include <initializer_list>
5
6 struct counter
7 {
8 static int n;
9
10 counter() { ++n; }
11 counter(const counter&) { ++n; }
12 ~counter() { --n; }
13 };
14
15 int counter::n = 0;
16
17 struct X
18 {
19 X () { if (counter::n > 1) throw 1; }
20
21 counter c;
22 };
23
24 int main ()
25 {
26 try
27 {
28 auto x = { X{}, X{} };
29 }
30 catch (...)
31 {
32 if ( counter::n != 0 )
33 throw;
34 }
35 }