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

Matthieu Monrocq matthieu.monrocq at gmail.com
Tue Jul 24 10:31:25 PDT 2012


On Mon, Jul 23, 2012 at 8:55 PM, Steve Ramsey <clang at lucena.com> wrote:

> On Jul 23, 2012, at 9:52 AM, Matthieu Monrocq wrote:
> > So I would argue against the owner here: what is the cost, really, of
> declaring the destructor virtual ? (especially since there is already
> another virtual method anyway)
>
> Well, if you want to avoid deprecated behavior, once you declare a virtual
> destructor, even if it’s just defaulted, you also have to declare the five
> other special member functions to maintain the existing behavior.
>
>
Which is probably a good thing, by the way.

The default (copy|move) (constructor|assignment operator) open the gate to
undiagnosed object slicing, so in the worst case they would have to be
protected (+defaulted) and in the best case disabling is just a bonus.

-- Matthieu



> Which reminds me: I don’t follow the standard proceedings at all, but why
> shouldn’t the implicitly declared destructor in a class with a virtual
> member function not be made virtual by default? The only other option that
> makes sense is to make it protected and nonvirtual, though that is probably
> less often what the class designer wants. I thought this might change in
> C++11, and find it makes even more sense given the new rules about special
> member functions.
>
>                         Steve
>
> P.S. If it were me, I’d just suck it up and fix the base class. The
> maintainer here seems to be spending more time arguing than it would take
> to implement the correct action.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120724/fc8c0d8c/attachment.html>


More information about the cfe-dev mailing list