Re: [boost] throw_exception rev. 44954 -> g++ warnings

Thanks for the explanation! How about this? Index: counted_base.hpp =================================================================== --- counted_base.hpp (revision 45067) +++ counted_base.hpp (working copy) @@ -34,6 +34,10 @@ protected: +// avoid warning: has virtual functions but non-virtual destructor +#if defined(__GNUC__) + virtual +#endif ~counted_base() throw() { } Index: cloning_base.hpp =================================================================== --- cloning_base.hpp (revision 45067) +++ cloning_base.hpp (working copy) @@ -23,6 +23,10 @@ protected: +// avoid warning: has virtual functions but non-virtual destructor +#if defined(__GNUC__) + virtual +#endif ~cloning_base() throw() { } ----- Original Message ---- From: Peter Dimov <pdimov@pdimov.com> To: boost@lists.boost.org Sent: Saturday, May 3, 2008 7:08:06 AM Subject: Re: [boost] throw_exception rev. 44954 -> g++ warnings Ralf W. Grosse-Kunstleve:
My primary question still is: What is the disadvantage of adding the virtual destructors? The Stroustrup book has a very clear recommendation (below). Why not follow this advice? I'm keen to learn the facts.
A destructor that is never supposed to be called (except by the destructor of the derived class) doesn't need to be virtual. There's not much point in trying to avoid the undefined behavior in "delete sp.get()". sp is now a time bomb. A protected destructor, on the other hand, yields a compile-time error. You can still make it virtual if you like. It's a bit contradictory for the reader as you appear unable to make up your mind as to whether the destructor is supposed to be part of the base class interface or not, but most of them are familiar with g++ by now, so they won't be confused for long. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Peter Dimov
-
Ralf W. Grosse-Kunstleve