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