[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: specific instantiation of static members from template class
From: cedric <cedric.borgese () gmail ! com>
Date: 2005-11-17 15:45:44
Message-ID: 200511171645.44172.cedric.borgese () gmail ! com
[Download RAW message or body]
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 ?
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic