http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46839
Summary: Parser confuses derived member with std::forward Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: foe...@informatik.uni-kl.de Created attachment 22673 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22673 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