https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43105

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jeffrey Yasskin from comment #0)
> programs don't link when a -frtti class is derived from a -fno-rtti base
> class.

It's more complicated than that. The ABI defines when RTTI is emitted:
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-rtti

There's only a problem when compiling a key function with -fno-rtti, and other
translation units compiled with -frtti have no way to know how the key function
was compiled.

For example, given:

struct A {
  A();
  ~A();
};

struct B {
  B();
  virtual ~B() { }
};

struct C {
  C();
  virtual ~C();
};

A and B can always be derived from unconditionally. If C::~C() is compiled with
-fno-rtti then classes that derive from C must also use -fno-rtti to compile
their key function (and if they don't have a key function, then all uses of C
that need a definition must be compiled with -fno-rtti).

I don't think this can be fixed. Documenting it is non-trivial.

I went to see what Clang does, and I can't even find -frtti / -fno-rtti in the
manual, so we're doing better than that!

Reply via email to