2 // GROUPS passed destructors
3 // Check that virtual destructors work correctly. Specifically,
4 // check that when you destruct an object of a derived class for
5 // which the base class had an explicitly declared virtual destructor
6 // no infinite recursion occurs.
9 // The generated g++ code apparently calls the base class destructor via
10 // the virtual table, rather than directly. This, of course, results in the
11 // infinite recursion.
13 extern "C" int printf (const char *, ...);
31 struct derived : public base
38 derived::derived() : base()
42 int derived_destructor_calls = 0;
44 extern void exit (int);
48 if (++derived_destructor_calls > 2)
59 { printf ("FAIL\n"); return 1; }