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

RE: Is this a bug for gcc (2.95 and 3.1)?




> -----Original Message-----
> From: Alexandre Oliva [mailto:aoliva@redhat.com]
> Sent: Saturday, May 25, 2002 11:15 AM
> To: Bernard Dautrevaux
> Cc: 'Mitchell Maggie'; gcc@gcc.gnu.org
> Subject: Re: Is this a bug for gcc (2.95 and 3.1)?
> 
> 
> On May 24, 2002, Bernard Dautrevaux 
> <Dautrevaux@microprocess.com> wrote:
> 
> > the compiler should flag your programs with an error message,
> > reporting that it's illegal to declare a destructor as pure
> 
> Err...  Care to cite the standard?  AFAIK, it's always been legal to
> declare a destructor as pure virtual, as long as it is defined
> (outside the class body) if it's actually used.
> 

My fault... I mixed "inheritable" and "overridable" ;-( 

You can't inherit destructors but you can override them, so you can declare
them as pure virtual (if you also define them, but not inline as Matthias
pinpoint in a later message). 

However I'm a bit puzzled by your "if it's actually used" above. As class A
was abstract it can only be used through a derived class, but overriding of
destructors, even if possible, is a bit special as the overriding destructor
always contains a call to th ebase class destructor. 

So if class A is more than just a test case to the compiler (that is, if it
is meant to be used) then the pure virtual destructor must always be
defined.

        Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux@microprocess.com
-------------------------------------------- 


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