🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Tom Vijlbrief Wed, 02 Aug 1989 09:54
Virtual destructors: Cfront and G++ incompatible?
#77
Author: Tom Vijlbrief
Date: Wed, 02 Aug 1989 09:54
53 lines
1626 bytes
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
===============================================================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads