1 // check cleanup of template temporaries 2 extern "C" void abort (); 3 extern "C" void exit (int); 4 5 int ctor = 0; 6 int dtor = 0; 7 8 template <class T> struct A { AA9 A() {ctor++;} AA10 A(int) {ctor++;} AA11 A(const A&) {ctor++;} ~AA12 ~A() {dtor++;} 13 operator int() {return 0;} 14 }; 15 16 template <class T> void ff(T); 17 ff(T)18template <class T> void ff(T) 19 { 20 } 21 g(int)22void g(int) 23 { 24 } 25 f()26void f() 27 { 28 int x; 29 30 A<int> a1; 31 A<double> a2(37); 32 A<long> a3 = A<long>(47); 33 A<short> a4 = 97; 34 35 g(A<char*>()); 36 37 A<char**>(); 38 39 x ? A<char*>() : A<char*>(); 40 41 x = 47, A<double*>(), A<int>(39), A<void>(23), -17; 42 43 while (A<short>()) 44 ; 45 for (;A<unsigned>(3);) 46 ; 47 if (A<A<double> >()) 48 ; 49 50 ff(A<double>()); 51 52 throw 59; 53 } 54 55 int main()56main() 57 { 58 int flag = 0; 59 60 try { 61 A<unsigned long>(); 62 f(); 63 } 64 catch (int) { 65 A<float>(34); 66 flag = 1; 67 } 68 69 if (!flag) 70 abort(); 71 72 if (!ctor || ctor != dtor) 73 abort(); 74 75 exit(0); 76 } 77