Inside the destructor, the this pointer is well defined, as are all members and bases (which will be destroyed in the reverse order of the construct after the destructor returns). Therefore, printing the address to which it refers is not UB.
The only thing is that the object itself cannot be considered "polymorphic", since the derived components have already been destroyed.
class A { public: virtual void fn() { std::cout << "A::fn" << std::endl; } virtual ~A() { fn(); }
source share