Whenever you override an associate function that's not virtual inside a class without any virtual functions, Versus compilers happens the "_BLOCK_TYPE_IS_VALID" error.

For instance,

class A{
    int a;
    void func(){}

class B : public A{
    virtual void func(){}


int main(void){
    A* a = new B();
    delete a;  // error!

    return 0;

I suppose the reason being in primary(), the a has vtable however the compiler misses it and should not obtain the exact size the header?

Somebody could possibly get my fascination with this shattered?

Thanks ahead of time.

You are able to remove A::func() and also the program continues to be erroneous.

The actual reason is the fact that A::~A() (not B::~B()) has been known as with an object of type B.

See C++ FAQ § 20.7 "When should my destructor be virtual?"

You are attempting to destroy an item using pointer towards the base class, however the destructor isn't virtual. If your class is a component of the inheritance hierarchy, always make dtors virtual.