------- Comment #4 from dannysmith at users dot sourceforge dot net 2009-05-10 05:01 ------- (In reply to comment #3) > Created an attachment (id=17841) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17841&action=view) [edit] > inherit dllexport from class to typeinfo > > Now testing a solution based on the approach of adding the dllexport attribute > to the class' typeinfo object when the class is passed to > i386_pe_adjust_class_at_definition. > Hello Dave, Rather than use DLL linkage (and so force client to resort to auto-import magic) why not just always emit the RTTI with one-only comdat linkage.
* decl2.c (import_export_decl): Always emit RTTI with comdat linkage rather than import if MULTIPLE_SYMBOL_SPACES. Index: decl2.c =================================================================== --- decl2.c (revision 147015) +++ decl2.c (working copy) @@ -2351,15 +2351,21 @@ { class_type = type; import_export_class (type); - if (CLASSTYPE_INTERFACE_KNOWN (type) - && TYPE_POLYMORPHIC_P (type) - && CLASSTYPE_INTERFACE_ONLY (type) - /* If -fno-rtti was specified, then we cannot be sure - that RTTI information will be emitted with the - virtual table of the class, so we must emit it - wherever it is used. */ - && flag_rtti) - import_p = true; + /* Do not import typeinfo if the class might be in a DLL. + Dllimports do not have a constant address at compile time, + causing problems for static initialization of tables with RTTI + fields. Set to comdat instead. */ + if (MULTIPLE_SYMBOL_SPACES) + comdat_p = true; + else if (CLASSTYPE_INTERFACE_KNOWN (type) + && TYPE_POLYMORPHIC_P (type) + && CLASSTYPE_INTERFACE_ONLY (type) + /* If -fno-rtti was specified, then we cannot be sure + that RTTI information will be emitted with the + virtual table of the class, so we must emit it + wherever it is used. */ + && flag_rtti) + import_p = true; else { if (CLASSTYPE_INTERFACE_KNOWN (type) -- dannysmith at users dot sourceforge dot net changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |dannysmith at users dot |dot org |sourceforge dot net Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2009-05-10 05:01:24 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40068