hash: do not insert deleted value to a hash_set

PR lto/108330

gcc/ChangeLog:

	* lto-cgraph.cc (compute_ltrans_boundary): Do not insert
	NULL (deleleted value) to a hash_set.

gcc/testsuite/ChangeLog:

	* g++.dg/ipa/pr108830.C: New test.
This commit is contained in:
Martin Liska
2023-01-09 09:51:01 +01:00
parent 7afecddf1e
commit fb082e3293
2 changed files with 22 additions and 1 deletions

View File

@@ -918,7 +918,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
vec <cgraph_node *>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++)
{

View File

@@ -0,0 +1,20 @@
// PR lto/108330
// { dg-do compile }
class A {
virtual unsigned long m_fn1() const;
virtual int &m_fn2(unsigned long) const;
};
class C : A {
public:
int &m_fn2(unsigned long) const;
unsigned long m_fn1() const;
};
class B {
void m_fn3(const A &, const int &, const C &, int &) const;
};
void B::m_fn3(const A &, const int &, const C &, int &) const {
C &a(a);
for (long b = 0; a.m_fn1(); b++)
a.m_fn2(0);
}