[cfe-dev] is delete on abstract with non-virtal ever safe?

emmanuel.attia emmanuel.attia at philips.com
Sat Oct 5 10:26:35 PDT 2013


> So the Standard is unambiguous: either `delete` shall be called on a
pointer to the most derived object or, > if called on a base sub-object, the
destructor of the corresponding sub-class shall be virtual.

In my example the default delete operator (not the overloaded one) is called
only on the (my_destroy_default_impl *) static type, that has a virtual
destructor.

> Thus your usecase of linking two libraries with incompatible new/delete
> pairs should work as-is providing
> you take care that the virtual dispatch to the destructor selects the
> right definition of operator delete.

I will look into this, thanks.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/is-delete-on-abstract-with-non-virtal-ever-safe-tp4025653p4034905.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list