Invoking a pure virtual method inside constructor or destructor during object destruction.
Occurs when code attempts to invoke an unimplemented pure virtual function (`virtual void func() = 0;`), often caused by calling virtual functions inside base class constructors or destructors.
In C++, during base class construction/destruction, the object's virtual table (vtable) points to the base class, not derived overrides.
1#include <iostream>2 3class Base {4public:5 Base() {6 // Bug: Calling pure virtual method inside constructor!7 render();8 }9 virtual void render() = 0;10 virtual ~Base() {}11};12 13class Derived : public Base {14public:15 void render() override { std::cout << "Derived render\n"; }16};17 18int main() {19 Derived d; // Program crashes with pure virtual function call!20 return 0;21}1#include <iostream>2 3class Base {4public:5 Base() {}6 virtual void render() = 0;7 virtual ~Base() {}8};9 10class Derived : public Base {11public:12 Derived() {13 // Safe: Called after Base construction finishes14 render();15 }16 void render() override { std::cout << "Derived render\n"; }17};18 19int main() {20 Derived d; // Output: Derived render21 return 0;22}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
When `Base` constructor executes, `Derived` part is not constructed yet. `render()` points to `Base::render()` which is an unimplemented pure virtual entry (`nullptr`), causing crash.