http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/C_002b_002b-Dialect-Options.html#index-fno_002drtti-148 doesn't mention any restrictions on compiling programs with some translation units compiled with -frtti, and others compiled with -fno-rtti. Yet there are such restrictions. For example, programs don't link when a -frtti class is derived from a -fno-rtti base class. Any restrictions like that should be documented or fixed.
Redoing https://gcc.gnu.org/ml/gcc-bugs/2017-08/msg01628.html Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2017-08-14 CC| |egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> --- Confirmed, text in the current docs is still pretty much the same as it was in 4.4.3.
cc-ing docs co-maintainers
(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!
It sounds to me like the right solution here is just to add a vague warning that mixing -frtti and -fno-rtti code may not always work, citing the base class example in the issue problem statement. WDYT?
Works for me.
Author: sandra Date: Sun Nov 11 22:46:00 2018 New Revision: 266020 URL: https://gcc.gnu.org/viewcvs?rev=266020&root=gcc&view=rev Log: 2018-11-11 Sandra Loosemore <sandra@codesourcery.com> PR c++/43105 gcc/ * doc/invoke.texi (C++ Dialect Options): Add warning about mixing -frtti and -fno-rtti code. Modified: trunk/gcc/ChangeLog trunk/gcc/doc/invoke.texi
Fixed on trunk.