🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by James Clark Sun, 16 Apr 1989 14:47
virtual destructor bug
#1867
Author: James Clark
Date: Sun, 16 Apr 1989 14:47
49 lines
1575 bytes
The following script illustrates a bug in the handling of virtual
destructors:

Script started on Sun Apr 16 15:42:30 1989
jclark%  cat test.c
#include <stdio.h>

struct foo {
  virtual ~foo() { fputs("~foo\n", stderr); }
};

struct member {
  ~member() { fputs("~member\n", stderr); }
};

struct bar : foo {
  member m;
};

main()
{
  foo *p = new bar;
  delete p;
  putc('\n', stderr);
  bar *q = new bar;
  delete q;
}
jclark%  ./g++ -B./ -v test.c
g++ version 1.34.2
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ test.c /tmp/cca07833.cpp
GNU CPP version 1.34
 ./c++ /tmp/cca07833.cpp -quiet -dumpbase test.c -version -o /tmp/cca07833.s
GNU C++ version 1.34.2 (sparc) compiled by GNU C version 1.34.
 as /tmp/cca07833.s -o test.o
 ./ld++ -C -C ./crt0+.o test.o -lg++ /usr/local/lib/gcc-gnulib -lc
jclark% a.out
~foo

~member
~foo
jclark% exit
jclark% 
script done on Sun Apr 16 15:43:04 1989

I think ~member() should get called for both deletions. Adding an empty 
definition of ~bar() makes things work correctly.

James Clark
jjc@jclark.uucp
virtual destructor bug
#1868
Author: Michael Tiemann
Date: Sun, 16 Apr 1989 19:39
3 lines
559 bytes
This is fixed in what will be 1.35.0.

Michael
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