This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Alpha g++ 2.95.2 template class static variable initialization failure
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Alpha g++ 2.95.2 template class static variable initialization failure
- From: Scott Davies <scottd at cs dot cmu dot edu>
- Date: Sat, 9 Sep 2000 16:53:59 -0400
- CC: scottd at cs dot cmu dot edu
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