Hi
I have just upgraded from gcc-3.3.3 to gcc-4.0.0 Trying to compile some
old code I stumbled over an error. I created this short example:
-------------------- gcctest.cpp -----------------------------
#include <iostream>
using namespace ::std;
template <class T>
class A {
public:
A (void) {}
template <class X>
class A& foo (X p) { // no error without "class"
cout << "template foo\n";
return(*this);
}
};
int main (void) {
A<double> a1, a2;
a1.foo(a2); // line 22: error (see below)
exit(0);
}
--------------------------------------------------------------------
no errors when compiling it with g++-3.3.3, but g++-4.0.0 (and
g++-3.4.1) complaints:
gcctest.cpp: In function ‘int main()’:
gcctest.cpp:22: error: template argument required for ‘struct A’
gcctest.cpp:22: error: no matching function for call to
‘A<double>::foo(A<double>&)’
Substituting "class A&" by just "A&" in foo it compiles without any
warnings or errors (and works as expected). Does this make any sense,
or is it a bug?