pure virtual method called C/C++ Origin: Application & API Last updated 15 Oct 2026

C++: pure virtual method called — terminate called without an active exception

A pure virtual function was called on an object that is being constructed or destroyed, where the derived part no longer exists.

Exact message you may see pure virtual method calledundefined reference to `__cxa_pure_virtual'pure virtual function calledR6025 pure virtual function call
Seen on: C/C++ GCC Clang MSVC

Meaning

During a base-class constructor or destructor the object's dynamic type is the base, so a virtual call resolves to the base version — which is pure and has no body. The same happens when another thread calls a method on an object that is mid-destruction, or after the object has been deleted.

Common causes

  • Calling a virtual function from a base-class constructor or destructor
  • Object used after delete (dangling pointer)
  • Thread calling methods while the object is destroyed
  • Slicing a derived object to its base

⚡ Quick fix

  1. Don't call virtual functions from constructors and destructors
  2. Use a separate init() step or a factory function after construction
  3. Make the destructor virtual and manage lifetime with smart pointers

Detailed fix by platform

C++

  1. Move the virtual call out of the constructor into a named start() method called after construction
  2. Use std::shared_ptr / std::weak_ptr when another thread needs the object

Code examples

The trap

cpp
struct Base {
    Base()  { setup(); }              // calls Base::setup (pure!) during construction
    virtual void setup() = 0;
    virtual ~Base() = default;
};
struct Derived : Base {
    void setup() override {}
};
// Derived d;  -> "pure virtual method called" / terminate

// Fix: call setup() after construction, e.g. Derived d; d.setup();

How to diagnose

  1. Context — Called from a constructor or destructor?
  2. Lifetime — Could the object already be deleted?
  3. Threads — Another thread using it?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

AddressSanitizer: heap-buffer-overflow — C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N (C/C++)AddressSanitizer: hea…AddressSanitizer: heap-use-after-free — C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free (C/C++)AddressSanitizer: hea…Assertion failed — C/C++: Assertion `x > 0' failed. Aborted (core dumped) — assert() condition was false (C/C++)Assertion failedcall of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…cannot declare variable to be of abstract type — C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) (C/C++)cannot declare variab…terminate called without an active exception — C++: terminate called without an active exception — std::thread destroyed while joinable (C/C++)terminate called with…undefined reference to vtable — C++: undefined reference to `vtable for X' — virtual function not defined (C/C++)undefined reference t…pure virt…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.