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++/77561] New: Unclear diagnostic for invalid declaration of partial specialization as friend


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

            Bug ID: 77561
           Summary: Unclear diagnostic for invalid declaration of partial
                    specialization as friend
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template <typename T, typename U> class A { };

template <typename T>
class B {
  template <typename U> friend class A<T, U>;
};

G++ says:

ps.cc:5:38: error: specialization of ‘template<class T, class U> class A’ must
appear at namespace scope
   template <typename U> friend class A<T, U>;
                                      ^~~~~~~

The user is not trying to declare a specialization, they're trying to define a
friend. The error should tell them that is allowed, instead of telling them
they're doing it in the wrong place.

Clang says:

ps.cc:5:32: error: partial specialization cannot be declared as a friend
  template <typename U> friend class A<T, U>;
                               ^      ~~~~~~

EDG says:

"ps.cc", line 5: error: a friend declaration may not declare a partial
          specialization
    template <typename U> friend class A<T, U>;
                                       ^

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