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

            Bug ID: 88176
           Summary: Overload resolution chooses template non-member
                    operator over non-template member operator
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Simon.Richter at hogyros dot de
  Target Milestone: ---

Similar to #78291:

    struct foo
    {
        foo operator+(foo const &rhs) const { throw; }
    };

    template<typename T>
    auto operator+(T const &lhs, foo const &rhs) -> decltype(rhs + lhs)
    {
        return rhs + lhs;
    }

    void test()
    {
        foo f1, f2;
        f1 + f2;
    }

This fails to compile because the template is evaluated recursively. I'd expect
the non-template overload to win.

MSVC compiles this correctly.

Reply via email to