This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++] Weffc++/Wnon-virtual-dtor confusion

On 2014.03.31 at 14:03 +0100, Nathan Sidwell wrote:
> This patch fixes some unexpected behaviour of the Weffc++ and Wnon-virtual-dtor 
> flags.  The documentation for the latter says it's also enabled by Weffc++, but 
> that's untrue.
> The current behaviour of Weffc++ is to warn about any non-virtual dtor in a 
> non-polymorphic base class (relying on the below described -Wnon-virtual-dtor 
> case to catch polymorphic classes).  Since Edition 3 of Scott Meyer's book, the 
> rule has been that it only applies to polymorphic classes.  I.e.  a polymorphic 
> class should not have an accessible non-virtual destructor and all of its bases 
> should be likewise. (it's possible earlier editions stated this rule too, but 
> 3rd ed was what I could find).
> The current behaviour of Wnon-virtual-dtor is to complain about accessible 
> non-virtual dtors in polymorphic classes.  This is what one expects.
> One surprising outcome of the current implementation is that -Weffc++ 
> -Wno-non-virtual-dtor still complains about the lack of virtual dtors in base 
> classes.
> This patch:
> 1) Clarifies the documentation for -Wnon-virtual-dtor to be for polymorphic 
> classes and bases of such classes. (i.e. move the 3rd ed Weffc++ behaviour into 
> this flag).

I'm not sure that this is a good idea. This changes the existing
behavior of -Wnon-virtual-dtor and causes hundreds of new warnings when
building LLVM. Wouldn't it make more sense to move the 3rd ed Weffc++
behavior to the -Weffc++ flag alone?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]