This is the mail archive of the gcc@gcc.gnu.org mailing 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]

static template initialization pb


I believe the current standard should allow initialization in the
declaration, so this should work:

template<class T>
struct X {
  static T c = 0;
};

//template<class T> T X<T>::c = 0;

X<int> W;

#include <iostream.h>

main () {
  cout << W.c << endl;
}
-----------------------

Here's what happens with 971127 (linux):

g++ -o Test2 Test2.cc
/tmp/cca002091.o: In function `main':
/tmp/cca002091.o(.text+0x9): undefined reference to `X<int>::c'
collect2: ld returned 1 exit status


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