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

Steve Ramsey clang at lucena.com
Mon Jul 23 11:55:06 PDT 2012


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 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. 





More information about the cfe-dev mailing list