specific instantiation of static members from template class (original) (raw)

This is the mail archive of the gcc@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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 #include "Test.h"

int main(int argc, char **argv) { std::cout << TestInt::member << std::endl; return 0; }

///// test.h template class Test { public:

static T member;

};

typedef Test TestInt;

///// test.cpp #include "Test.h"

template class Test; template<> int Test::member;

I got an error at link because it cannot find the symbol Test::member used in "main.o" If I use only one file, it works. If I give an initial value to Test::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 ?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]