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

Дмитрий Оксенчук oksenchuk89@gmail.com
Wed Apr 14 11:35:00 GMT 2010


Ian Lance Taylor <iant@google.com> writes:
> Read about the key method and type_info objects here:
>
> http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html
>
> I won't go into all the details, but basically if you mix -frtti and
> -fno-rtti code you need to ensure that any classes created in the
> -frtti code have their key method compiled with -frtti.

Thank you for your report.

As I understand B key method is auto generated ~B() and compiler
creates it in main compilation unit with type_info object. Even this
object never been used compiler creates it anyway. Right?
So type_info for B needs type_info for A and ask linker to find it.
Linker can't find it, because A key method and vtable was created with
-fno-rtti.

And the last question: does the type_info object for B really need in
main.cpp or compiler creates it just in case?



More information about the Gcc-help mailing list