http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54376
--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> 2012-08-26 07:54:41 UTC --- Created attachment 28087 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28087 Alternate solution What about this (completely untested) other solution? (reindentation is needed after the patch, but too many white space changes make patches hard to read). Then the only special case is normal_distribution, which befriends operator== for all template parameters, not just its own (not that it can cause any issue). Being friend only with your own operator== is complicated when you put its definition outside the class, so I guess it makes sense to leave it that way.