This is the mail archive of the gcc-bugs@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]

Alpha g++ 2.95.2 template class static variable initialization failure



The compiler doesn't appear to emit any code to initialize static
members of template classes under certain circumstances.  Example code:

//////////////////
#include <iostream.h>

template <class T> class Ooga
{
public:
  T t;
  static char* blah[];
};

template <class T> char* Ooga<T>::blah[] = {"I", "hate", "computers"};

int main(int argc, char* argv[])
{
  Ooga<int> ooga;
  cout << ooga.blah[1] << endl;
  return 0;
}
///////////////////
Result of an attempt to compile it:
>/bin/ld:
>Unresolved:
>Ooga<int>::blah

A friend of mine verified that this still failed with the latest
snapshot, and said that the assembly code indicated that the compiler 
simply failed to emit any code for the initializer.  (Oddly enough,
this compiles just fine with Linux g++ 2.95.2.)

-- Scott

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