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

Eli Friedman eli.friedman at gmail.com
Mon Jul 23 10:05:00 PDT 2012

On Mon, Jul 23, 2012 at 7:29 AM, Henry Miller <hank at millerfarm.com> wrote:
> I'm trying to settle an argument we are having at work.  Right now our
> code doesn't compile with clang because of a code like below.
> I understand (and agree with) the warning, however the owner of this
> code argues that only the default destructors are used, and they have
> procedures in place to ensure that no derived class will ever have
> members that need destruction.  So the question is he correct that the
> destructor for derived doesn't need to be called?

Strictly speaking, the C standard says it's undefined behavior.  It's
not completely unrealistic that it could break with a really well
optimized implementation of "delete".  That said, you can probably get
away with it on existing C++ implementations.


More information about the cfe-dev mailing list