non virtual dtor warning

Rupert Wood me@rupey.net
Mon Feb 25 12:19:00 GMT 2008


James Tebneff wrote:

> g++-svn -Weffc++ -Wno-non-virtual-dtor t.c
> t.c:2: warning: base class struct A has a non-virtual destructor
:
> Is it possible to use -Wno-non-virtual-dtor or otherwise to disable
> that warning?

You'll find that warning in cp/class.c. It's switched only on -Weffc++:

  /* Effective C++ rule 14.  We only need to check TYPE_POLYMORPHIC_P
     here because the case of virtual functions but non-virtual
     dtor is handled in finish_struct_1.  */
  if (!TYPE_POLYMORPHIC_P (basetype))
    warning (OPT_Weffc__,
             "base class %q#T has a non-virtual destructor", basetype);

So no, sorry, there's no way to disable that warning individually. -Wnon-virtual-dtor controls another similar warning that (at first glance) is triggered only if there are virtual functions.

Given -Weffc++ in c-opts.c implies -Wnon-virtual-dtor there could be a case for making the above warning conditional on both -Weffc++ and -Wnon-virtual-dtor.

Rup.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________



More information about the Gcc-help mailing list