https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65157
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) Note if I change d not to be a template, then GCC is able to recognize the friend and the code compiles.