https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107379
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- In (untested) patch form: --- gcc/cp/name-lookup.cc.jj 2022-10-12 17:51:00.912944731 +0200 +++ gcc/cp/name-lookup.cc 2022-10-26 12:06:38.177590655 +0200 @@ -8596,6 +8596,13 @@ push_namespace (tree name, bool make_inl /* This should find the slot created by pushdecl. */ gcc_checking_assert (slot && *slot == ns); } + else + { + /* pushdecl could have expanded the hash table, so + slot might be invalid. */ + slot = find_namespace_slot (current_namespace, name); + gcc_checking_assert (slot); + } make_namespace_finish (ns, slot); /* Add the anon using-directive here, we don't do it in which fixes the ICE for me on the cross-compiler.