It's used to fill the vtable slot of a virtual function that has been defined as deleted:
struct B { virtual void f() = delete; };
struct D : B { virtual void f() = delete; };
(The reason a deleted virtual function is included in the vtable is that this allows it to be later changed to non-deleted without breaking vtable layout.)
I'm not aware of any way it could actually get called in (relatively sane) C++, since the only thing that can override a function with a deleted definition is another function with a deleted definition ([class.virtual]/16), and any attempt to call a function with a deleted definition renders the program ill-formed. I suppose you can invoke the specter of ODR violations:
// TU 1
struct B { virtual void f() = delete; virtual void g(); };
void B::g() { } // causes vtable to be emitted in this TU
// TU 2
struct B { virtual void f(); virtual void g(); };
void h(B* b) { b->f(); }
int main() {
B b;
h(&b);
}
__cxa_pure_virtual
a while ago, trying to debug the sudden increase in size of my (embedded) binary - despite my efforts to create a minimal "buggy" program, I couldn't have it linked in. I'd love to see C++ gurus' insight on this. – Glochidiatestruct base { virtual void f() {} }; struct derived : base { void f() = delete; }; int main() { derived d; base& b = d; b.f(); }
, but that refuses to compile. I wonder if you need a compiler which doesn't reject that code? – Diptych