[Bug c++/71227] New: template friend function cannot be resolved

ppwwyyxxc at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun May 22 18:42:00 GMT 2016


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

            Bug ID: 71227
           Summary: template friend function cannot be resolved
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppwwyyxxc at gmail dot com
  Target Milestone: ---

The following code gives error with 6.1.1 on up-to-date ArchLinux. However it
works for g++-5. Is there some standard about this I'm missing, or is it a bug?

class A {
  public:
    template<typename T>
      friend int f(int x, T v) {
        return x + v;
      }
};


template<>
int f(int x, int v) {
  return x + v;
}

$ g++ b.cpp
b.cpp:15:19: error: ‘f’ is not a template function
 int f(int x, int v) {


More information about the Gcc-bugs mailing list