re PR c++/12253 ([tree-ssa] ICE on conversion to std::string inside array initialization)
[gcc.git] / gcc / testsuite / g++.dg / init / array12.C
1 // PR c++/12253
2 // Bug: We were failing to destroy the temporary A passed to the
3 // constructor for b[0] before going on to construct b[1].
4
5 // { dg-do run }
6
7 extern "C" int printf (const char *, ...);
8
9 int c;
10 int r;
11
12 struct A
13 {
14 A() { printf ("A()\n"); if (c++) r = 1; }
15 A(const A&) { printf ("A(const A&)\n"); ++c; }
16 ~A() { printf ("~A()\n"); --c; }
17 };
18
19 struct B
20 {
21 B(int, const A& = A()) { printf ("B()\n"); }
22 };
23
24 int main()
25 {
26 B b[] = { 0, 0 };
27 return r;
28 }