https://gcc.gnu.org/g:03c7145a4175c452362b5d1e2fa5f83dc8a01d18
commit r15-5570-g03c7145a4175c452362b5d1e2fa5f83dc8a01d18 Author: Jason Merrill <ja...@redhat.com> Date: Wed Nov 20 13:51:10 2024 +0100 c++: modules and tsubst_friend_class In 20_util/function_objects/mem_fn/constexpr.cc we start to instantiate _Mem_fn_base's friend declaration of _Bind_check_arity before we've loaded the namespace-scope declaration, so lookup_imported_hidden_friend doesn't find it. But then we load the namespace-scope declaration in lookup_template_class during substitution, and so when we get around to pushing the result of substitution, they conflict. Fixed by calling lazy_load_pendings in lookup_imported_hidden_friend. gcc/cp/ChangeLog: * name-lookup.cc (lookup_imported_hidden_friend): Call lazy_load_pendings. Diff: --- gcc/cp/name-lookup.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 2dca57a14fd8..769879976420 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -4569,6 +4569,8 @@ lookup_imported_hidden_friend (tree friend_tmpl) || !DECL_MODULE_IMPORT_P (inner)) return NULL_TREE; + lazy_load_pendings (friend_tmpl); + tree bind = get_mergeable_namespace_binding (current_namespace, DECL_NAME (inner), DECL_MODULE_ATTACH_P (inner)); if (!bind)