http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56328
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-14 20:45:35 UTC --- Also, [basic.def.odr]: "An inline function shall be defined in every translation unit in which it is odr-used." and [dcl.fct.spec] "If a function with external linkage is declared inline in one translation unit, it shall be declared inline in all translation units in which it appears; no diagnostic is required." To fix the program you need to declare the explicit specialization in main.cpp and neither foo<T> nor foo<2> can be inline unless they're defined in both translation units.