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++/78291] New: overload resolution prefers non-member operator to member operator when should be ambiguous


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

            Bug ID: 78291
           Summary: overload resolution prefers non-member operator to
                    member operator when should be ambiguous
           Product: gcc
           Version: 6.2.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: ---

This example:

struct A {
    template <class T>
    void operator==(T const& ) const;

    template <class T>
    friend void operator==(T const&, A const& ) { }
};

int main() {
    A{} == A{};
}

compiles and runs (tried 4.8.2, 5.4, 6.2, and 7.0). gcc picks the non-member
overload here. But both overloads are equally viable, so this should be
ambiguous.

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