1 // Some targets (e.g. those with "set_board_info needs_status_wrapper 1"
2 // in their dejagnu baseboard description) require that the status is
3 // final when exit is entered (or main returns), and not "overruled" by a
4 // destructor calling _exit.  It's not really worth it to handle that.
5 // { dg-do run { target unwrapped } }
6 
7 // Bug: g++ was failing to destroy C<int>::a because it was using two
8 // different sentry variables for construction and destruction.
9 
10 extern "C" void _exit (int);
11 
12 int r = 1;
13 
14 struct A
15 {
fA16   void f(){}
AA17   A(){ ++r; }
~AA18   ~A(){ r -= 2; _exit (r); }
19 };
20 
21 template<class T>
22 struct C
23 {
CC24   C(){ a.f(); }
25   static A a;
26 };
27 
28 template <class T> A C<T>::a;
29 typedef C<int> B;
30 
main()31 int main()
32 {
33   C<int> c;
34   return r;
35 }
36