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

            Bug ID: 101138
           Summary: Ambiguous code (with operator==) compiled without
                    error
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

$ cat test.cpp

#include <iostream>
using namespace std;

template<typename T>
struct D {
    template<typename Y> bool operator==(Y a) const { 
        cout << "f" <<endl;
        return false;
    }
};

template<typename T, class Y> 
bool operator==(T a, D<Y> b) { 
    cout << "fD" <<endl;
    return false;
}

int main()
{
    D<struct ok> a, b;
    if (a == b)
        return 0;
    return 1;
}

gcc compiles this code fine, bug clang errors out.

https://godbolt.org/z/c13EExxeY

Reply via email to