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

--- Comment #13 from Jan Hubicka <hubicka at ucw dot cz> ---
Thanks, Jason!
This is patch I am testing that cures the testcase from Comment #7. I would
apprechiate if someone could reduce it - my simple attempts has failed and I am
bit in hurry this week.

The problem here is that get_dynamic_class gets into placement new paranoia
because
it manages to mismatch polymorphic_type[2] with polymorphic_type.

Honza

Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c    (revision 214225)
+++ ipa-devirt.c    (working copy)
@@ -2846,6 +2891,18 @@ ipa_polymorphic_call_context::get_dynami
   bool function_entry_reached = false;
   tree instance_ref = NULL;
   gimple stmt = call;
+  /* Remember OFFSET before it is modified by restrict_to_inner_class.
+     This is because we do not update INSTANCE when walking inwards.  */
+  HOST_WIDE_INT instance_offset = offset;
+
+  /* Walk into inner type. This may clear maybe_derived_type and save us
+     from useless work.  It also makes later comparsions with static type
+     easier.  */
+  if (outer_type)
+    {
+      if (!restrict_to_inner_class (otr_type))
+        return false;
+    }

   if (!maybe_in_construction && !maybe_derived_type)
     return false;

Reply via email to