[Bug c++/24933] New: Function template friend declaration is misinterpreted.

seefeld at sympatico dot ca gcc-bugzilla@gcc.gnu.org
Fri Nov 18 19:39:00 GMT 2005


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



More information about the Gcc-bugs mailing list