[Bug c++/16190] make -Wnon-virtual-dtor more sophisticated
ncm-nospam at cantrip dot org
gcc-bugzilla@gcc.gnu.org
Sat Jun 26 16:30:00 GMT 2004
------- Additional Comments From ncm-nospam at cantrip dot org 2004-06-26 16:24 -------
> ... it is still valuable [as] a warning for -Wall because it *does*
> help many people. The few of us who can abuse C++ correctly at will can
> specify -Wnon-virtual-dtor and be done with it.
A fundamental design criterion for regular warnings (absent ideological
maunderings as implemented in -Weffc++) is that it must be possible for
users to fix the cause, and quiet the warning, without otherwise damaging
the code. This one fails on two counts. First, a user might not have
write access to the header involved, and (as proposed) there's nothing
that can be done at the point of deletion, even if it _is_ in user's
code; it might also be in somebody else's header, as noted earlier.
Second, patching the class definition changes the ABI for the class,
and pessimizes the code, because in some circumstances the destruction
can no longer be brought in-line.
The claim that it's OK to have a bad warning, because "users can say
-Wno-non-virtual-dtor" is trivially fallacious. It balances with the
assertion, "users who actually want the warning are free to say
-Wnon-virtual-dtor". The problem is that the situation is not symmetric.
While the warning might occasionally catch a bug, it fails (in its
existing form and in every proposed alternative) to satisfy the base
criterion for an acceptable warning. If "-Wall" starts accumulating
spurious warnings, then I (and most users) will have to stop using
"-Wall" routinely, as we are used to.
Warnings in -Weffc++ don't have to satisfy normal criteria. That's the
right place for this one. Once it's there, somebody can tighten up its
specificity at his leisure. In the meantime it won't be actively harmful,
because people using -Weffc++ expect spurious warnings.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |minor
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16190
More information about the Gcc-bugs
mailing list