I am experimenting with overloading operator delete, so that I can return a plain pointer to those who don\'t wish to work with smart pointers, and yet be able to control wh
You've misused just every C++ concept possible and this causes errors. When delete p;
is called for the first time C++ calls the Cat::~Cat()
destructor which implicitly destroys the std::string
inside the entity. When delete p;
is called the second time Cat::~Cat()
is rerun and it reruns the destructor of the std::string
and this causes undefined behavour crashing the program because I suppose std::string::~string()
doesn't nullify the pointer to the buffer and so when std::string::~string()
tries to release the buffer for the second time with the same address this leads to famous double-free.