Hi,
fold_ctor_reference expects VAR or FUNCTION_DECL as FROM_DECL parameter.
gimple_get_virt_method_for_binfo instead passes expression
(pointer_plus_expr (addr_expr vtable_decl) (integer_cst XXX))
This bug makes can_refere_from_current_unit_p to mistakely think that
the references are safe because they come from code.

Fixed thus,
Bootstrapped/regtested x86_64-linux.

Honza

        * gimple-fold.c (gimple_get_virt_method_for_binfo): Pass real
        VAR_DECL of vtable rather than full expression.
Index: gimple-fold.c
===================================================================
--- gimple-fold.c       (revision 202445)
+++ gimple-fold.c       (working copy)
@@ -3135,7 +3135,7 @@ gimple_get_virt_method_for_binfo (HOST_W
   size = tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (v))), 1);
   offset += token * size;
   fn = fold_ctor_reference (TREE_TYPE (TREE_TYPE (v)), init,
-                           offset, size, vtable);
+                           offset, size, v);
   if (!fn || integer_zerop (fn))
     return NULL_TREE;
   gcc_assert (TREE_CODE (fn) == ADDR_EXPR

Reply via email to