1 // { dg-do run }
2 
3 #include <assert.h>
4 
5 extern "C" int printf(const char *, ...);
6 
7 class Subscriptor
8 {
9   public:
10 
Subscriptor()11   Subscriptor()
12     { counter = 1;}
13 
~Subscriptor()14   virtual ~Subscriptor()
15   {
16     counter--;
17     assert(counter == 0);
18   }
19 
20   private:
21     static int counter;
22 };
23 
24 int Subscriptor::counter;
25 
26 template <typename number>
27 class Polynomial : public Subscriptor
28 {
29 };
30 
31 class LagrangeEquidistant: public Polynomial<double>
32 {
33 };
34 
35 template <int value>
36 class A
37 {
38  public:
39   class Nested: public LagrangeEquidistant
40   {
41   };
A()42   A() { n = new Nested; }
~A()43   ~A() { delete n; }
44   Subscriptor * n;
45 };
46 
47 template<typename _Tp>
48 inline void
_MyDestroy(_Tp * __pointer)49 _MyDestroy(_Tp* __pointer)
50   { __pointer->~_Tp(); }
51 
main()52 int main()
53 {
54   Subscriptor * s1 =  new  LagrangeEquidistant;
55   _MyDestroy(s1);
56   A<1> * a1 = new A<1>;
57   _MyDestroy(a1);
58   A<2> * a2 = new A<2>;
59   _MyDestroy(a2);
60 
61   return 0;
62 }
63