Thread View: gnu.g++.bug
1 messages
1 total messages
Started by James Clark
Thu, 27 Apr 1989 19:25
virtual destructor fails to be called
Author: James Clark
Date: Thu, 27 Apr 1989 19:25
Date: Thu, 27 Apr 1989 19:25
40 lines
1428 bytes
1428 bytes
g++ can fail to call the appropriate virtual destructor:
Script started on Thu Apr 27 20:13:54 1989
jclark% cat delete.c
#include <stdio.h>
struct A {
virtual ~A() { fputs("~A\n", stderr); }
};
struct B : A {
};
struct C : B {
~C() { fputs("~C\n", stderr); }
};
main()
{
B *p = new C;
delete p;
}
jclark% g++ -g -v delete.c
g++ version 1.34.1
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ delete.c /tmp/cca04129.cpp
GNU CPP version 1.34
/usr/local/lib/gcc-c++ /tmp/cca04129.cpp -quiet -dumpbase delete.c -g -version -o /tmp/cca04129.s
GNU C++ version 1.34.1 (sparc) compiled by GNU C version 1.34.
as /tmp/cca04129.s -o delete.o
/usr/local/lib/gcc-ld++ -C -e start -dc -dp -Bstatic /usr/local/lib/crt0+.o delete.o -lg++ /usr/local/lib/gcc-gnulib -lg -lc
jclark% a.out
~A
jclark% exit
jclark%
script done on Thu Apr 27 20:14:35 1989
If p is declared as an A*, ~C() gets called as it should.
James Clark
jjc@jclark.uucp
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