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

            Bug ID: 66914
           Summary: incorrect template partial ordering prefers non-member
                    function instead of being ambiguous
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

The following code:

#include <iostream>

template <typename N>
struct A {
    template <typename T>
    void operator+(T const&) { 
        std::cout << "member\n"; 
    }
};

template <typename N>
void operator+(A<N>&, int const& ) { 
    std::cout << "free\n"; 
}

int main()
{
    A<int> a;
    a + 2;
}

compiles and prints "free". It should be ambiguous as neither function template
is more specialized than the other.

Reply via email to