[llvm-bugs] [Bug 51887] New: Unambiguous use of operator==considered ambiguous.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 17 04:51:46 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51887

            Bug ID: 51887
           Summary: Unambiguous use of operator==considered ambiguous.
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: qtom.boehmer at googlemail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following compiles fine with gcc, but with clang gives the error: "use of
overloaded operator '==' is ambiguous".

----------------------------------------------------
#include <cassert>

template<typename T>
bool operator==(T const&, T const&)
{
        return false;
}

template<int I>
struct S
{
        template<int J>
        constexpr
        bool operator==(S<J> const&) const
        {
                return true;
        }
};

int main()
{
        auto i = S<0>{};
        auto j = S<0>{};

        assert(i == j);
}
----------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210917/4535724b/attachment.html>


More information about the llvm-bugs mailing list