This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]