Created attachment 22673 [details] Info about gcc build configuration 01: #include <iostream> 02: #include <utility> 03: using namespace std; 04: 05: template <typename T> struct A 06: { 07: T forward; 08: A() : forward(0) {} 09: }; 10: 11: template <typename T> struct B : public A<T> 12: { 13: void Function() 14: { 15: cout << (this->forward > 1) << endl; 16: cout << (this->forward < 1) << endl; 17: } 18: }; 19: 20: int main(int argc, char **argv) 21: { 22: return 0; 23: } g++ -Wall -std=gnu++0x : In member function ‘void B<T>::Function()’: :16: error: parse error in template argument list Used compiler version: gcc version 4.4.3 (Gentoo 4.4.3-r2 p1.2) 4.3 and 4.5 versions show the same behavior. It seems, that in line 16 "forward <" is parsed as the beginning of a template instantiation. To get this effect, the inclusion of <utility>, using namespace std and using derived members in a template class is necessary. Maybe, using namespace typically appears after template definition in other h-files, but a scenario like this might occur. Apart from that: Would "this->std::forward<...>" be valid C++ code? Therefore, I think that is a bug in the parsers which neglects the occurrence of this and starts to interpret forward as the std::forward template. Regards, Tobias Föhst
I forgot: Line 15 is only there to prove that this->forward with another successor than '<' can be resolved as the member derived from A<T>.
Note that Intel compiler, based on the EDG C++ front-end, also rejects this code in strict mode. Likewise of course Comeau. This is enough to show the issue: template<typename T> void forward(T); template <typename T> struct A { T forward; }; template <typename T> struct B : public A<T> { void Function() { this->forward < 1; } };
See PR 20308 and such. *** This bug has been marked as a duplicate of bug 20308 ***