Building std.compat.cc was crashing for me because we would first get a
pointer into imported_temploid_friends, then insert a new entry, causing the
hash_map to expand, and then dereference the pointer into the former
location of the hash table. Fixed by dereferencing the pointer before
inserting rather than after.
gcc/cp/ChangeLog:
* module.cc (transfer_defining_module): Dereference
pointer into hash_map before possible insertion.
DECL_MODULE_IMPORT_P (old_inner) = false;
}
- if (tree *orig = imported_temploid_friends->get (newdecl))
+ if (tree *p = imported_temploid_friends->get (newdecl))
{
+ tree orig = *p;
tree &slot = imported_temploid_friends->get_or_insert (olddecl);
if (!slot)
- slot = *orig;
- else if (slot != *orig)
+ slot = orig;
+ else if (slot != orig)
/* This can happen when multiple classes declare the same
friend function (e.g. g++.dg/modules/tpl-friend-4);
make sure we at least attach to the same module. */
gcc_checking_assert (get_originating_module (slot)
- == get_originating_module (*orig));
+ == get_originating_module (orig));
}
}