It is known that we can use pure virtual destructors, like this:
struct A {
virtual ~A() = 0;
};
A::~A() {}
struct B : A {};
Because the Standard says in 10.4 [class.abstract] p2
A pure virtual function need be defined only if called ... with (12.4 [class.dtor])
And later in 12.4 [class.dtor] p9
A destructor can be declared virtual (10.3) or pure virtual (10.4); if any objects of that class or any derived class are created in the program, the destructor shall be defined.
What means that the code above is perfectly valid - A::~A
may be pure virtual, it is defined, B::~B
implicitly calls A::~A
.
So far, so good.
And then I read 10.4 [class.abstract] p6
:
Member functions can be called from a constructor (or destructor) of an abstract class; the effect of making a virtual call (10.3) to a pure virtual function directly or indirectly for the object being created (or destroyed) from such a constructor (or destructor) is undefined.
But that's exactly what we do here - we call a pure virtual function A::~A
from a destructor.
So, isn't there some kind of contradiction?