🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #77

Virtual destructors: Cfront and G++ incompatible?

#77
From: 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
===============================================================================
Technical Details
Message-ID: <473@tnosoes.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!mcvax!hp4nl!tnosoes!tom

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!mcvax!hp4nl!tnosoes!tom
From: tom@tnosoes.UUCP (Tom Vijlbrief)
Newsgroups: gnu.g++
Subject: Virtual destructors: Cfront and G++ incompatible?
Keywords: g++
Message-ID: <473@tnosoes.UUCP>
Date: 2 Aug 89 09:54:41 GMT
Organization: TNO Institute for Perception, Soesterberg, The Netherlands
Lines: 53