This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16713] New: call of template member function rejected
- From: "marco at technoboredom dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jul 2004 10:54:35 -0000
- Subject: [Bug c++/16713] New: call of template member function rejected
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code compiles on Intel Compiler for Linux 8.0 and Microsoft Visual
C++ 7.1, but is rejected by gcc:
/* BEGIN */
template<class T>
void fail1()
{
T::f<T>();
}
/* END */
results in the error message:
marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -c a.cc
a.cc: In function `void fail1()':
a.cc:5: error: expected primary-expression before '>' token
a.cc:5: error: expected primary-expression before ')' token
marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -v
Reading specs from /opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: /usr/local/src/gcc/source/gcc-3.4.1/configure -v
--prefix=/opt/gcc-3.4.1 --enable-shared --disable-checking --verbose
--with-gnu-as --with-gnu-ld --enable-__cta_atexit --enable-threads=posix
Thread model: posix
gcc version 3.4.1
Suspecting this as a parsing problem, I found this possible variation:
/* BEGIN */
template<class T>
void fail2()
{
T::f<0,0>(0);
}
class X
{
public:
template<int x, int y> void f(int);
};
int x()
{
fail2<X>();
}
/*END*/
This results in the following message:
marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -c a.cc
a.cc: In function `void fail2() [with T = X]':
a.cc:14: instantiated from here
a.cc:4: error: invalid operands of types `<unknown type>' and `int' to binary
`operator<'
I therefore guess, that gcc parses:
T::f<0,0>(0);
as
(T::f<0) , (0>(0))
And fails in:
T::f<T>();
Because it thinks:
(T::f<T) >();
--
Summary: call of template member function rejected
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marco at technoboredom dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-slackware-linux
GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16713