This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Pure virtual destructor bug ?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]