http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56328
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-15 09:11:29 UTC --- (In reply to comment #4) > (In reply to comment #2) > > The foo<2> specialization is not declared in main.cpp before it would be > > needed, so the program is ill-formed, no diagnostic required, according to > > [templ.expl.spec]/6. > > If I declare the foo<2> specialization in main.cpp, it does not change > anything. > > > Also, the following paragraph is relevant: > > "When writing a specialization, be careful about its location, or to make it > > compile will be such a trial as to kindle its self-immolation." > > I think this does not apply here (does it?), as it doesn't work even if I > declare foo<2> in both files after the base template. You also have to stop declaring functions inline in one file only.