When the line that requests explicit template instantation is before the actual template class method definitions, g++ 4.0 and 4.1 fail to generate the code for those methods, resulting in linking errors later. But gcc 3.3 and 3.4 both have no problems (as well as icc and msvc). Moving the "template class foo<5>;" line after the definitions fixes this. I'm not sure what the C++ standard says about that... -- Steps to reproduce -- Grab the attached simple testcase. Issue "make" -- Actual results -- Linking fails. -- Expected results -- Should link successfully. -- Build date and platform -- gcc 4.1.0 (fedora core 5 default) -- Additional builds and platforms -- - Also occurs on - gcc 4.0.1 (fedora core 4 defulat) - DOESN't work - Doesn't occur on - gcc 3.3.6 (slackware 10.2 default) gcc 3.4 (fedora core 3 default)
Created attachment 11275 [details] A testcase that exploits the bug
GCC is correct. Please read PR 24511 and DR 470 to learn more. *** This bug has been marked as a duplicate of 24511 ***