https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114889
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:390bd23fd9c98dc40856beef05364f5d1c7b9d04 commit r14-10176-g390bd23fd9c98dc40856beef05364f5d1c7b9d04 Author: Patrick Palka <ppa...@redhat.com> Date: Mon Apr 29 21:27:59 2024 -0400 c++/modules: imported spec befriending class tmpl [PR114889] When adding to CLASSTYPE_BEFRIENDING_CLASSES as part of installing an imported class definition, we need to look through TEMPLATE_DECL like make_friend_class does. Otherwise in the below testcase we won't add _Hashtable<int, int> to CLASSTYPE_BEFRIENDING_CLASSES of _Map_base, which leads to a bogus access check failure for _M_hash_code. PR c++/114889 gcc/cp/ChangeLog: * module.cc (trees_in::read_class_def): Look through TEMPLATE_DECL when adding to CLASSTYPE_BEFRIENDING_CLASSES. gcc/testsuite/ChangeLog: * g++.dg/modules/friend-8_a.H: New test. * g++.dg/modules/friend-8_b.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit 22b20ac6c6aead2d3f36c413a77dd0b80adfec39)