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)


-- 
           Summary: No code generated for Explicit Template Instantations on
                    gcc 4.0+
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: skalaren_alpinist at abv dot bg
 GCC build triplet: i386-pc-gnu
  GCC host triplet: i386-pc-gnu
GCC target triplet: i386-pc-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27175

Reply via email to