https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119863
--- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
FWIW, in the meantime a workaround is to do
// ...
template<typename>
class U
{
template<typename>
friend class ::T;
};
// ...
instead.
