http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57746
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Andy Lutomirski from comment #4) > Daniel, I'm unconvinced that your interpretation is the intended one. The definition is also a declaration, see [basic.def] p2, as Daniel pointed out. > [temp.explicit].4 says "A declaration of [list including member function] > ... A definition of [list not including member function]". If definitions > were intended to be declarations in this context, then the second part would > be redundant, I think. That doesn't follow at all. The second part describes different types of entities that have different requirements. For the first list an explicit instantiation must follow a declaration (and a definition also counts as a declaration) but for the second list an explicit instantiation must follow a definition, a declaration is not sufficient. > Regardless, the interesting case is: > > template<typename T> > struct X > { > static int val; > static void func(); > }; > > // optionally: extern template struct X<int>; > > void something() > { > X<int>::func(); > } > > in one file and > > struct X > { > static int val; > static void func(); > }; > > template<> void X<int>::func() {} > > in another. I don't think this is an odr violation, since there is only one > definition of anything that could be confused with X<int>::func. g++ will > happily compile and link it (without the extern template bit) and it will > work. It is supposed to? Could a conforming compiler mangle the > specialized version of func differently? Isn't this ill-formed, with no diagnostic required, by both [temp] p6 and [temp.expl.spec] p6?