From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux 2.4.2-2 i686; en-US; 0.7) Gecko/20010316
Description of problem:
return a.f<int>(); //this works
return a.f<int>(); //this doesn't
Steps to Reproduce:
1. Compile above code (no special compiler switches necessary).
2. See error
Actual Results: testgcctemplatebug.cpp: In method `int B::h ()':
testgcctemplatebug.cpp:23: parse error before `>'
Expected Results: Code would compile.
If you make A::f into a static function (and call it using "A::f" syntax),
or a global function, it works. Even stranger, if you make a global
function f which is defined the same as the member function, but you still
call the member function version from B::g, it works.
If you give f an argument of type T*, and you instantiate the template
based on the argument rather than manually specifying the type, that works
too. For now, I am working around the bug by allowing a dummy template
argument to be used to instatiate the template.
I suppose I am not entirely sure if the above code is valid C++, but the
only other compiler I could test on is MSVC. Needless to say, it won't
compile the code either. But that doesn't mean much, now does it? :)
I am using gcc 2.96-85.
It does not compile with g++ 2.95.2 and g++ 3.0 either.
I don't have ISO C++ standard with me ATM, so I'd suggest you take this
to comp.lang.c++ or something like that.
Well, I asked on comp.lang.c++, and the two responses I received both said that they
are pretty sure that is was a compiler bug. One guy said that he had reported the same
bug to the GCC 3.0 people and had received no reply. He also said that Borland C++
compiles it just fine.
Fixed in the gcc 3.4 c++ parser rewrite.