🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Bj|rn Gr|nvall Mon, 22 May 1989 08:40
Destructors for virtual bases get called on the wrong objects.
#2023
Author: Bj|rn Gr|nvall
Date: Mon, 22 May 1989 08:40
67 lines
2361 bytes
MACHINE
	sun4 running os4.01
VERSION
	g++ 1.35.0+
BUG DESCRIPTION
	When calling the virtual base class destructor the wrong this pointer
	is passed. Search for *** here it is ***.

Script started on Mon May 22 10:28:48 1989
spirit-1> cat tst.cc
// -*- C++ -*-

#include <stream.h>
#define sp <<" "
#define nl <<"\n"

class base {
protected:
  int i;
public:
  base() { cout << int(&i) sp << "making base\n"; }
  ~base() { cout << int(&i) sp << "deleting base\n"; }
};

class left : public virtual base {
public:
  left() { cout << int(&i) sp << "making left\n"; }
  ~left() { cout << int(&i) sp << "deleting left\n"; }
};

class right : public virtual base {
public:
  right() { cout << int(&i) sp << "making right\n"; }
  ~right() { cout << int(&i) sp << "deleting right\n"; }
};

class derived : public left, public right, public virtual base {
public:
  derived() : left(), right() { cout << int(&i) sp << "making derived\n"; }
  ~derived() { cout << int(&i) sp << "deleting derived\n"; }
};

int main() {
  derived foo;
  return 0;
}
spirit-2> g++ -v tst.cc
g++ version 1.35.0+
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ tst.cc /tmp/cca01767.cpp
GNU CPP version 1.35
 /usr/local/lib/gcc-cc1plus /tmp/cca01767.cpp -quiet -dumpbase tst.cc -noreg -version -o /tmp/cca01767.s
GNU C++ version 1.35.0+ (sparc) compiled by GNU C version 1.35.
 as /tmp/cca01767.s -o tst.o
 /usr/local/lib/gcc-ld++ -C /usr/local/lib/crt0+.o tst.o -lg++ /usr/local/lib/gcc-gnulib -lc
spirit-3> ./a.out
-134219356 making base
-134219356 making left
-134219356 making right
-134219356 making derived
-134219356 deleting derived
-134219356 deleting right
-134219356 deleting left
-134219368 deleting base 		<- *** here it is ***.
spirit-4> exit
exit

script done on Mon May 22 10:29:25 1989
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