2 // GROUPS passed destructors
3 // Check that member and base classes get properly destructed
4 // when an object of a derived class is destructed via a pointer
5 // to it which only has a "compile-time" type of "pointer-to-base".
7 // Note that in order for this test to work properly, the destructor
8 // for the base class should be explicitly declared to be virtual.
10 extern "C" int printf (const char *, ...);
12 int member_destructor_calls = 0;
13 int middle_destructor_calls = 0;
27 struct middle : public base {
31 ~middle (); // should be implicitly virtual
34 struct derived : public middle {
42 base* bp = new derived;
44 derived *dp = new derived;
47 if ((member_destructor_calls != 8) || (middle_destructor_calls != 2))
48 { printf ("FAIL\n"); return 1; }
55 member_type::~member_type ()
57 member_destructor_calls++;
66 middle_destructor_calls++;