This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24933] New: Function template friend declaration is misinterpreted.
- From: "seefeld at sympatico dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Nov 2005 19:38:59 -0000
- Subject: [Bug c++/24933] New: Function template friend declaration is misinterpreted.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code results in an error:
namespace Foo { template <typename T> void foo();}
struct Bar
{
friend void Foo::foo<int>();
};
The error is:
/home/stefan/friend.cc:4: error: ?void Foo::foo()? should have been declared
inside ?Foo?
I've briefly attempted to debug this. Here are my findings:
At some point set_decl_namespace() is called for the friend
declaration, which itself then checks the function against
existing declarations in an iteration over the overload set.
In case of a non-templated function, decls_match() would return
true, but for the above function template it doesn't match,
and so we enter the 'complain' label.
Sorry I wasn't able to decipher the actual tree comparisons.
HTH...
--
Summary: Function template friend declaration is misinterpreted.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: seefeld at sympatico dot ca
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24933