This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
specific instantiation of static members from template class
- From: cedric <cedric dot borgese at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 17 Nov 2005 16:45:44 +0100
- Subject: specific instantiation of static members from template class
- Reply-to: cedric dot borgese at gmail dot com
hello, I have a problem when I try to instantiate static members. this code
works with gcc-3.4.5 but not with gcc-4.0.2 (debian sid).
here a test case with 3 files :
///// main.cpp
#include <iostream>
#include "Test.h"
int main(int argc, char **argv)
{
std::cout << TestInt::member << std::endl;
return 0;
}
///// test.h
template <class T>
class Test
{
public:
static T member;
};
typedef Test<int> TestInt;
///// test.cpp
#include "Test.h"
template class Test<int>;
template<> int Test<int>::member;
I got an error at link because it cannot find the symbol Test<int>::member
used in "main.o"
If I use only one file, it works.
If I give an initial value to Test<int>::member in test.cpp, it works.
It works with gcc-3.4.5.
I did some research and see that it could works even without the member
declaration, the class instantiation should be enough here :
http://gcc.gnu.org/ml/gcc/2004-05/msg01393.html
Is this a bug or a behavour change from gcc ?