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

            Bug ID: 68138
           Summary: "operator== is ambiguous" when comparing a tuple
                    containing values with one containing refs
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: officesamurai at gmail dot com
  Target Milestone: ---

Created attachment 36610
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36610&action=edit
test code (also in the text)

The test code is:

#include <tuple>

struct T
{
    bool operator==(const T&) const
    {
        return true;
    }
};

int main()
{
    T t;
    std::tuple<T, T> t1;
    std::tuple<T&, T&> t2(t, t);

    bool b = t1 == t2;
}


The result is:


g++ test.cpp  -std=c++11
test.cpp: In function ‘int main()’:
test.cpp:17:20: error: request for member ‘operator==’ is ambiguous
     bool b = t1 == t2;
                    ^
test.cpp:5:10: note: candidates are: bool T::operator==(const T&) const
     bool operator==(const T&) const
          ^
test.cpp:5:10: note:                 bool T::operator==(const T&) const


Note: Clang is able to compile this code even when libstdc++ is used.

Reply via email to