This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c++/16190] spurious warning about non-virtual destructor


------- Additional Comments From ncm at cantrip dot org  2004-06-25 18:34 -------
(In reply to comment #5)
> I would claim that in most cases the compiler warning is actually 
> justified.  

The warning could possibly be justified in "pure OO" programming, 
but C++ is not restricted to pure OO. There is a place set aside 
specifically for "pure OO" warnings, and that place is -Weffc++.
  
> The question what we put into -Wall is always a judgment call, so 
> reasonable people may disagree whether a particular warning should be 
> in it or not.  However, it should be undisputed that moving individual 
> warnings from one general class to another one is bad, since it forces 
> people to rewrite their makefiles if they want this warning. Given that 
> one can switch this warning off separately, I will close this PR. 

I _do_ dispute that moving a warning from one general class to another 
is necessarily bad.  In particular, moving a warning that is subject to
frequent false positives to a class specifically meant for such warnings 
is all to the good.  The move cannot break normal Makefiles, because no 
new warnings would be issued for code that previously evoked no warnings.
Anyone specificially asking for nanny-ish advice can still get it via 
an appropriate "nanny-ish-advice-please" option.

Consider when this warning occurs.  You #include a header for a library
to whose headers you have no write access.  For every compilation unit 
that includes it, you see this spurious warning.  You probably don't 
know that there is a separate option to turn it off.  Instead, you 
start avoiding "-Wall".  Even if it is made more specific, such as to 
be triggered only by "new" of a derived class that also doesn't declare 
a virtual destructor, it's still far from clear that it belongs in 
"-Wall".  (E.g., consider mixins.)  The correct immediate action is to 
move it to "-Weffc++", and consider later whether to move it back after 
it has been made specific enough.  Even made as specific as possible, 
though, it would still produce too many false positives to be 
appropriate for "-Wall".

You might argue that it is easy to fix the code warned about, by 
adding "virtual" to the destructor declaration, and thereby suppress 
the warning.  However, such a change has both performance and ABI 
consequences.

Finally, it strikes me as contemptuous to close a bug only minutes 
after Gaby has asked that it be kept open.  Please change it back
to "minor".  Making the warning more specific would be an enhancement, 
but moving it to "-Weffc++" would fix the immediate problem, which 
is that it is warning improperly about a common and correct, albeit
not necesssarily purely "OO", coding practice.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16190


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