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

Tim Northover t.p.northover at gmail.com
Sat Oct 5 08:38:43 PDT 2013


> This doesn’t mean by chance there is no destructor so nothing bad happens,
> it mean if there is no destructor so, according to the standard, the
> compiler should consider the object alive until the memory is released.

There are multiple sub-objects under discussion here and only one of
them has a trivial destructor.

The standard appears to have stopped specifying behaviour at 5.3.5
("thou shalt have a virtual destructor") so the entire discussion is
moot. But I think it's difficult to argue that, had it skipped that
bit and gone on to define behaviour for your case, either the
my_destroy_default_impl or Toto objects would still be alive.

Tim.




More information about the cfe-dev mailing list