http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58300

--- Comment #6 from Caroline Tice <cmtice at google dot com> ---
When the preinit flag is used, the vtable verification constructor
initialization function was getting written to the assembly file before
cgraph_process_new_functions was being called (to process the new function),
which was causing an assertion failure in decide_is_symbol_needed (which
expects the symbol NOT to have its decl assembler name yet).  The fix is very
simple...reorder those two events.  This should not cause any errors.  I have a
patch that does this, which I have tested both on this test case and with the
new libvtv testsuite, and it passes in both places:

Index: gcc/cp/vtable-class-hierarchy.c
===================================================================
--- vtable-class-hierarchy.c    (revision 202296)
+++ vtable-class-hierarchy.c    (working copy)
@@ -1179,15 +1179,16 @@ vtv_generate_init_routine (void)
       TREE_USED (vtv_fndecl) = 1;
       DECL_PRESERVE_P (vtv_fndecl) = 1;
       if (flag_vtable_verify == VTV_PREINIT_PRIORITY)
-        {
-          DECL_STATIC_CONSTRUCTOR (vtv_fndecl) = 0;
-          assemble_vtv_preinit_initializer (vtv_fndecl);
-        }
+        DECL_STATIC_CONSTRUCTOR (vtv_fndecl) = 0;

       gimplify_function_tree (vtv_fndecl);
       cgraph_add_new_function (vtv_fndecl, false);

       cgraph_process_new_functions ();
+
+      if (flag_vtable_verify == VTV_PREINIT_PRIORITY)
+        assemble_vtv_preinit_initializer (vtv_fndecl);
+
     }
   pop_lang_context ();
 }


I will submit this patch for review soon.

Reply via email to