gcc 3.4.5 compiles the following cleanly:
struct Foo {
template<class T> int func() const;
};
class Bar {
friend int Foo::func<int>() const; // line 6
};
gcc 4.1.0, however, gives the following compile error for the same
code:
z:\proj\gccerr.cpp:6: error: template-id 'func<int>' for 'int
Foo::func<int>()' does not match any template declaration
But both gcc 3.4.5 and gcc 4.1.0 compile the code cleanly if I change
Foo::func to be non-const:
struct Foo {
template<class T> int func();
};
class Bar {
friend int Foo::func<int>(); // line 6
};
And Comeau compiles both versions of the code without errors.
So is this a bug in gcc 4.10?
Best regards,
Tom
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
class Bar {
friend template<class T> Foo::func<int>() const; // line 6
};
Your code is mal-formed:
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 2: error: omission of explicit type is nonstandard
("int"
assumed)
template<class T>func() const;
^
"ComeauTest.c", line 6: error: "template" is not allowed
Comeau C++ 4.2.43 and above supports template-template-parameters
OR You are using template in the wrong place
friend template<class T> Foo::func<int>() const; // line 6
In any case, I reported my test case to the gcc folks, who have
confirmed it as a compiler bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26912
Best regards,
Tom