===================================================================
@@ -1112,7 +1112,8 @@ ipa_get_indirect_edge_target (struct cgr
if (!ie->indirect_info->polymorphic)
{
- tree t = VEC_index (tree, known_vals, param_index);
+ tree t = (VEC_length (tree, known_vals) > param_index
+ ? VEC_index (tree, known_vals, param_index) : NULL);
if (t &&
TREE_CODE (t) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)
@@ -1126,7 +1127,7 @@ ipa_get_indirect_edge_target (struct cgr
otr_type = ie->indirect_info->otr_type;
t = VEC_index (tree, known_vals, param_index);
- if (!t && known_binfos)
+ if (!t && known_binfos && VEC_length (tree, known_binfos) > param_index)
t = VEC_index (tree, known_binfos, param_index);
if (!t)
return NULL_TREE;
===================================================================
@@ -0,0 +1,14 @@
+void
+foo (x, fn)
+ void (*fn) ();
+{
+ int a = baz ((void *) 0, x);
+ (*fn) (x, 0);
+}
+
+void
+bar (void)
+{
+ void *x = 0;
+ foo (x);
+}