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++/66914] New: incorrect template partial ordering prefers non-member function instead of being ambiguous


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.


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