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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$ 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux