Brainfart: GCC and templates (10)

1 Name: #!/usr/bin/anonymous : 2006-10-25 16:04 ID:yRl1iPbl

Trying to get back into C++ after only using python for almost a year. I ran into this one while trying out partial template specialization, narrowed it down to this simple test case...

#include <iostream>
using namespace std;
template <class T>
struct wtf {
T member;
wtf():member() {}
void message() {
cout << "this is wtf " << member << " ." << endl;
}
};
template <class T>
struct wtf2 : public wtf<T> {
void message() {
/* 1 */ cout << "this is wtf2 " << member << " " << endl;
// /* 2 */ cout << "this is wtf2 " << wtf<T>::member << " " << endl;
// /* 3 */ cout << "this is wtf2 " << this->member << " " << endl;
}
};
int main() {
wtf2<int> test;
test.message();
return 0;
}

The line marked with 1 makes my gcc throw a "member undeclared" (gcc 3.4.x) or "member: not declared in this score" error (gcc 4.0.x). Versions 2 and 3 compile fine. MSVC 2003 compiles all three versions. Removing the template from the wtf2 class and inheriting from a concrete base (for example wtf<int>) makes it work in gcc, too.

Now I'm pretty sure I'm doing something wrong here (I trust g++ to know the standard more than myself), but why is it that it barfs on something that looks this trivial? Is there some dumb name lookup / scope thing that I'm missing? :(

This thread has been closed. You cannot post in this thread any longer.