#include #include #include #define builtin_return_address(addr) ((char*)__builtin_return_address(addr) + libcwd::builtin_return_address_offset) template class A { int i; public: A(void) {}; }; template class B { int i; public: B(void) {}; ~B(void); }; template class C : public A, public B { int i; public: C(void) {}; }; template B::~B(void) { Dout(dc::notice, "Calling the destructor of " << libcwd::type_info_of(*this).demangled_name() << " (this == " << this << ")"); libcwd::alloc_ct const* alloc = libcwd::find_alloc(this); if (sizeof(*this) != alloc->size()) { Debug(dc::malloc.off()); Debug(libcw_do.push_marker()); Debug(libcw_do.marker().assign(": | ")); Dout(dc::notice, "This is a base class of an object starting at " << alloc->start()); Dout(dc::notice, "The type of the pointer to the allocated object is " << alloc->type_info().demangled_name()); Debug(libcw_do.marker().assign(": ` ")); Dout(dc::notice, "The destructor was called from " << location_ct(builtin_return_address(0))); Debug(dc::malloc.on()); Debug(libcw_do.pop_marker()); } } int main(void) { Debug(libcw_do.on()); Debug(dc::notice.on()); Debug(dc::malloc.on()); B* b = new B; // line 56 AllocTag(b, "object `b'"); Dout(dc::notice, "b is " << b); C >* c = new C >; // line 60 AllocTag(c, "object `c'"); Dout(dc::notice, "c is " << c); delete b; delete c; // line 65 return 0; }