This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: missing warning
- To: "Alexander V. Lukyanov" <lav at long dot yar dot ru>
- Subject: Re: missing warning
- From: bonnardv at pratique dot fr (Valentin Bonnard)
- Date: Thu, 26 Nov 1998 00:10:13 +0100
- Cc: egcs-bugs at cygnus dot com
A (At) 1:51 26/11/98, Alexander V. Lukyanov ecrivait (wrote):
>On Wed, Nov 25, 1998 at 10:26:00PM +0100, Valentin Bonnard wrote:
>> >So a warning could be wrong
>> >in any of the cases, thus better to have no warning.
>>
>> Sorry I don't follow this resonning.
>
>I mean, someone who uses something like this for purpose will not like the
>warning.
That's why it isn't an error: it can make sens in particular cases.
>E.g. it's possible to have base class without virtual destructor
>and never delete pointer to base class, or delete it when all derived
>classes don't have dtors too, etc. and the like.
>
>Well, maybe I'm wrong on this. Probably there are a lot of warnings for
>possibly legal code :) At least such warnings require a commonly accepted
>idea of good style, IMHO.
That's the point of -Wall not being the default.
Using public non virtual destructors in base classes is
discouraged by all style guides, by Effective C++, and is
generally a terrible idea.
When it's ok:
- for traits classes which inherit from other trait classes
There is a well-know example: BidirectionnalIteratorTag
inherits from ForwardIteratorTag, InputIteratorTag ect
- for meta programming, where a class is just a value,
and one never create instances of it (much delete them)
Most style rules aren't universally accepted; they apply
to one coding style but may be utter non-sens in another.
That's why they shouldn't be mandatory.
Making the dtor virtual when it is public is a generally
accepted rule. The rare exceptions don't IMO imply that we
should leave it outside -Wall, much less not implement
it at all (again there might be other reasons why it won't
be implemented).
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/