[gnu.g++] Virtual destructors: Cfront and G++ incompatible?

tom@tnosoes.UUCP (Tom Vijlbrief) (08/02/89)

The following program:
============================

#include	<stdio.h>

class a {
public:
  a() {}
  virtual ~a() { printf("~a\n"); IsA(); }
  virtual void IsA() { printf("I am a 'a'\n"); }
};

class b: public a {
public:
  b() {}
  virtual ~b() { printf("~b\n"); IsA(); }
  virtual void IsA() { printf("I am a 'b'\n"); }
};

main()
{
  b *p= new b;

  delete p;
}
============================
compiled with g++1.35 prints:

~b
I am a 'b'
~a
I am a 'a'
========================
G++ replaces the vtbl pointer of the 'b' object with the vtbl pointer
of an 'a' object before calling ~a. I think that this is the correct
behaviour, otherwise ~a could call virtual methods from 'b' which
is already destructed!

My question is: Does cfront 1.2 behave the same, or does it leave
the vtbl pointer unchanged when calling ~a ?

Could someone with access to cfront test this ?

Thanks !

Tom
===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================