This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Linker error: undefined reference to typeinfo for A with no-rtti option


$ g++ -c -o classes.o -fno-rtti classes.cpp
$ g++ -o test main.cpp classes.o
/tmp/ccmtJ65X.o:(.rodata._ZTI1B[typeinfo for B]+0x8): undefined
reference to `typeinfo for A'
collect2: ld returned 1 exit status

Code:
/* classes.h */
class A
{
public:
    virtual ~A();
};

class B: public A
{
};
/* end classes.h */

/* classes.cpp */
#include "classes.h"

A::~A()
{
}
/* end classes.cpp */

/* main.cpp */
#include "classes.h"

int main()
{
    B b_obj;
    return 0;
}
/* end main.cpp */

Linker doesn't say anything when i create any virtual function in B or
replace virtual ~A() to virtual void f() for example.

It seems like compiler doesn't create vtable for B class and try to
call ~B() using typeinfo for A, but what for?


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