* g++.dg/init/ref15.C: Require unwrapped targets.
[gcc.git] / gcc / testsuite / g++.dg / init / ref15.C
1 // PR c++/20416. We correctly constructed the temporary S in foo(),
2 // but incorrectly destroyed it every time foo() was called.
3 // When using a wrapped target, there is no way to override the exit
4 // code after returning from main.
5 // { dg-do run { target unwrapped } }
6 extern "C" void abort (void);
7 extern "C" void _exit (int);
8
9 int c, exiting;
10 struct S {
11 S() { ++c; }
12 S(const S &) { ++c; }
13 ~S()
14 {
15 if (!exiting) abort ();
16 _exit (0);
17 }
18 };
19 void
20 foo (void)
21 {
22 static const S &s = S();
23 }
24 int main ()
25 {
26 if (c != 0)
27 abort ();
28 foo ();
29 foo ();
30 if (c != 1)
31 abort ();
32 exiting = 1;
33 return 1;
34 }