This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17556] New: linker fails to find template
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Sep 2004 03:38:03 -0000
- Subject: [Bug c++/17556] New: linker fails to find template
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The attached .tar.gz dile explodes to the following:
1) a -v -save-temps compile of the library module "bitset.cc"; the compiler
output is "foolib", the save-temps is "bitset.ii".
2) a -v -save-temps of a compile of a test case "testBitset.cc" that uses the
library; the compiler output is "foowithlib" and the save-temnps is
"testBitset.iiwithlib". This fails to link because the linker cannot file a
template (operator<<) that is located in "bitset.cc".
3) a -v -save-temps of the same testcase modified to explicitly include the
source of "bitset.cc" inline rather than picking it up from the library. This
compiles and links OK, verifying that definition of the template in the
"bitset.c" does in fact satisfy the calls in the test case.
4) the binary "libs.a" which includes the result of compiling "bitset.cc" and
some other libraries. The linker does find other itams from that library even
when it fails to find the template in question, verifying that the link-time
file lookup is finding the library correctly. This binary is required to get the
testcase to link without error; however, you can link without it and ignore all
errors except the one shown in the failing link output.
My workaround is to make the template in question be an inline in the .hh file
(in which case everything compiles and links fine). However, it's not a small
function and the multiple inlines do cause code bloat in my application. I
intend to see if an explicit instantiation will also workaround, but haven't done it yet.
Ivan
--
Summary: linker fails to find template
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17556