Reset branch to trunk.
[official-gcc.git] / trunk / gcc / testsuite / g++.dg / init / ref15.C
blobbc9c01dc229bf72247589a6aa6ba73a3b2000b1f
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);
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   }
19 void
20 foo (void)
22   static const S &s = S();
24 int main ()
26   if (c != 0)
27     abort ();
28   foo ();
29   foo ();
30   if (c != 1)
31     abort ();
32   exiting = 1;
33   return 1;