This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46839] New: Parser confuses derived member with std::forward
- From: "foehst at informatik dot uni-kl.de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 7 Dec 2010 17:02:36 +0000
- Subject: [Bug c++/46839] New: Parser confuses derived member with std::forward
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: foehst@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