https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65152
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- So it sounds like the friend declaration injects 'test' into N and thus 'test' is found but overload resolution fails. Whether that injection is correct or not I don't know. But given you can even define the function there it is probably what is specified (C++11 11.3/6). So I think this bug is invalud.