https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59930

Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richard-gccbugzilla@metafoo
                   |                            |.co.uk

--- Comment #1 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
Another example, without the explicit instantiation:

namespace N {
  template<typename T> class A {
    template<typename U> friend struct B;
  private:
    int n;
  };
}

template<typename T> struct B {
  int f(N::A<int> ai) { return ai.n; }
};

int k = B<int>().f({}); // incorrectly accepted


It looks like when GCC instantiates a friend class template declaration, it
incorrectly injects it into the global namespace (rather than the innermost
enclosing namespace) if redeclaration lookup doesn't find some prior
declaration of the class template to befriend.

That would make at least bug#64816, bug#78724, and bug#81347 duplicates of
this.

Reply via email to