We should not insert an empty value to the container.
PR ipa/108509
gcc/ChangeLog:
* cgraphunit.cc (walk_polymorphic_call_targets): Insert
ony non-null values.
* ipa.cc (walk_polymorphic_call_targets): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/ipa/pr108509.C: New test.
= possible_polymorphic_call_targets
(edge, &final, &cache_token);
- if (!reachable_call_targets->add (cache_token))
+ if (cache_token != NULL && !reachable_call_targets->add (cache_token))
{
if (symtab->dump_file)
dump_possible_polymorphic_call_targets
= possible_polymorphic_call_targets
(edge, &final, &cache_token);
- if (!reachable_call_targets->add (cache_token))
+ if (cache_token != NULL && !reachable_call_targets->add (cache_token))
{
for (i = 0; i < targets.length (); i++)
{
--- /dev/null
+// PR ipa/108509
+// { dg-do compile }
+// { dg-options "-O1 -fdevirtualize -fno-tree-fre" }
+
+struct B {
+ virtual void deref ();
+};
+
+struct RefPtr {
+ B *p;
+
+ RefPtr ()
+ {
+ p->deref ();
+ }
+};
+
+void
+f ()
+{
+ RefPtr b;
+}