https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115915
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 60003 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60003&action=edit A better testcase This shows what is happening; basically this friend is causing to define a class extent in the namespace enclosed by class S. It happens for templates definitions.