Bug 24933 - Function template friend declaration is misinterpreted.
Summary: Function template friend declaration is misinterpreted.
Status: RESOLVED DUPLICATE of bug 8355
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2005-11-18 19:38 UTC by Stefan Seefeld
Modified: 2005-11-18 20:08 UTC (History)
5 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Seefeld 2005-11-18 19:38:59 UTC
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.

Comment 1 Andrew Pinski 2005-11-18 20:08:26 UTC
This is a dup of bug 8355.

*** This bug has been marked as a duplicate of 8355 ***