This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Parse error with member templates
- From: Matt Austern <austern at apple dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 13 Sep 2002 12:03:40 -0700
- Subject: Parse error with member templates
The following snippet fails to compile:
struct X {
template <class T> T* f() { return (T*) 0; }
};
template <class T>
int* g(T) {
X x;
return x.f<int>();
}
What's happening is that the second line in g() is
falling afoul of the parse ambiguity described in
14.2p4 of the C++ Standard: if you've got a dependent
name and you access a member template, you have to
write ".template f" instead of just plain "f".
Trouble is, I think the compiler is being a little too
eager to apply that rule here. The Standard says it
applies when "the postfix-expression or qualified-id
explicitly depends on a template-parameter", and I
don't see that that's the case here.
So, the usual two questions:
(1) Is there a plausible argument that I'm wrong, and
that this behavior is correct after all?
(2) If not, is this a known bug?
--Matt