This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Missing specialized method in object file
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: Missing specialized method in object file
- From: "Craig S. Kaplan" <csk at cs dot washington dot edu>
- Date: Tue, 6 Nov 2001 17:03:32 -0800 (PST)
I'm posting this here first because I'm not 100% certain
it's a bug. I'd like some feedback. If necessary, I'll
submit it to GNATS as appropriate. Thanks.
Here's a test file:
-------------------------------------------------------------------------------
#include <iostream>
template<typename T>
class A
{
public:
void func()
{
std::cout << "A<T>::func()" << std::endl;
}
};
void A<int>::func()
{
std::cout << "A<int>::func()" << std::endl;
}
-------------------------------------------------------------------------------
When this file is compiled with -c, the resulting object file doesn't
contain the specialized definition of A<int>::func(). Shouldn't it?
My understanding is that a specialized method of a templated class can
live in a separately-compiled object. But this test case shows that
this doesn't work, because the specialized method is thrown out. But
append the following to the file:
-------------------------------------------------------------------------------
static void x()
{
A<int> a;
a.func();
}
-------------------------------------------------------------------------------
The new object _does_ include A<int>::func, along with x. Thus, my
temporary workaround is to include such static functions that exercise
the specialized methods; this makes separate compilation work.
I welcome comments, better workarounds, confirmation of bugness, etc.
--
Craig. http://www.cs.washington.edu/homes/csk/
Counterfactuals: what would the world be like without them?