[Bug c++/11648] New: G++ parse error for simple template code
wwieser at gmx dot de
gcc-bugzilla@gcc.gnu.org
Wed Jul 23 20:42:00 GMT 2003
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.
More information about the Gcc-bugs
mailing list