Defined virtual functions cause type_info dependence

  abi, c++, gcc, linker

I have the following file foobar.cc:

struct Foo
{
  virtual int do_something() const = 0;
};

struct Bar : public Foo
{
  virtual int do_something() const override
  { return 1; }
};

Bar bar;

When I try to build a shared object out of it like so:

g++ -shared -fPIC foobar.cc -o foobar.so

nm foobar.so outputs the lines:

U [email protected]@CXXABI_1.3
U [email protected]@CXXABI_1.3

But why? Shouldn’t this only be the case if one of the virtual functions was not either pure or did not have a definition? I know I can circumvent this by compiling with fno-rtti but I’m trying to understand this behaviour.

Source: Windows Questions C++

LEAVE A COMMENT