https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102092
David Friberg <davveston at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |davveston at gmail dot com --- Comment #2 from David Friberg <davveston at gmail dot com> --- I believe your program has UB as it contains an odr-violation due to the friend declaration of the stream operator function , as its in-class definition ("hidden friend") makes use of the non-type template parameter 'Degree'. The hidden friend, albeit being inline (protection against multiple-TU odr-violations, given token-by-token identical definitions), will have multiple definitions that are not the same as soon as two specializations of the class template 'Polynomial' are instantiated if these two specializations differ in the 'Degree' template parameter. Recall that a non-template friend of a class template is in itself not a templated entity, but a namespace-scope function.