https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91418
--- Comment #4 from Darrell Wright <Darrell.Wright at gmail dot com> --- The weird part is, other than compilers don't agree, but the lookup finds it if you put the template argument in template<typename T> struct A { auto func( ) { class B { B( ) = default; friend class A<T>; }; return B( ); } }; I don't think a local class can be a template anyways, but it does find global A here