This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Pure virtual destructor bug ?
- To: egcs-bugs at cygnus dot com
- Subject: Pure virtual destructor bug ?
- From: "Munagala V. S. Ramanath" <ram at netcom dot com>
- Date: Fri, 9 Apr 1999 13:28:20 -0700 (PDT)
Hi,
Is there some reason pure virtual destructors are invalid ? The
followng test program produces errors with egcs-1.1.2:
------------------------------------------------------------------------
#include <fstream.h>
struct A {
A( ) { }
virtual ~A() = 0 ;
} ;
struct B : A {
B() { }
virtual ~B() { cerr << "~B() called" << endl ; }
} ;
int
main( int argc, char* argv[] )
{
B b ;
return 0 ;
}
------------------------------------------------------------------------
g++ -ansi -pedantic -Wall t.C
yields the following:
/tmp/ccpVD2Vq.o: In function `B::~B(void)':
t.C(.text+0x16c): undefined reference to `A::~A(void)'
t.C(.text+0x170): undefined reference to `A::~A(void)'
/tmp/ccpVD2Vq.o: In function `B::B(void)':
t.C(.text+0x30c): undefined reference to `A::~A(void)'
t.C(.text+0x310): undefined reference to `A::~A(void)'
collect2: ld returned 1 exit status
My version:
Reading specs from /usr/local/exper/lib/gcc-lib/alphaev56-unknown-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
The standard says in section 12.4 [class.dtor] para 7 page 192:
"A destructor can be declared virtual (10.3) or pure virtual (10.4) ..."
Ram