This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11648] New: G++ parse error for simple template code
- From: "wwieser at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2003 20:42:31 -0000
- Subject: [Bug c++/11648] New: G++ parse error for simple template code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11648
Summary: G++ parse error for simple template code
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wwieser at gmx dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-linux-gnu
GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu
Trying to compile following code...
-----------------<test.cc>---------------------
struct A
{
template<class T>T *foo();
};
template<class T>void bar(A *a)
{
a->foo<T>();
}
----------------------------------------------
...I get the following parse error:
test.cc: In function `void bar(A*)':
test.cc:8: error: parse error before `>' token
I am the opinion that the code above is legal C++.
If I replace the T by a #define, things work well:
--------------<good.cc>------------------
struct A
{
template<class T>T *foo();
};
#define T int
void bar(A *a)
{
a->foo<T>();
}
-----------------------------------------
Maybe there is a way how one could use brackets to
make the parser happy, but I was not able to find such
a construct.