gcc seems to have had a succession of warnings about non-virtual-
destructors-in-classes-with-virtual-methods, none of which really
worked all that well in practice (and so none are enabled by default,
even by -Wall or -Wextra).

But I notice clang has a variant which seems pretty well-behaved on
real code:

   struct X { virtual void m () = 0; };
   void test (X *x) { delete x; }

yields:

   $ clang++ -c dnvd.cc
   dnvd.cc:2:23: warning: delete called on 'X' that is abstract but has 
non-virtual
         destructor [-Wdelete-non-virtual-dtor]

By triggering at the point of _delete_, for a class type it knows
can't be the most-derived (because it's abstract), it avoids the
"well but I only ever delete most-derived-classes" false positive.

I had endless problems with false positives with all of gcc's various
non-virtual-dtor warnings, but I've had zero problems with this one,
and it's actually caught real bugs for me (and note that it's enabled
by default).

What do people think... is this a better non-virtual-dtor warning?

-miles

-- 
If you can't beat them, arrange to have them beaten.  [George Carlin]

Reply via email to