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

            Bug ID: 86751
           Summary: Ambiguous operator= overload for std::pair<T1, T2>
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

Following program does not compile since gcc 6.3
(this looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79141)

#include <utility>

struct dummy
{
    template <typename T>
    operator T() const
    {
        return {};
    }
};

int main()
{
    dummy d;
    std::pair<int, int> s;
    s = d;
}

Following error is produced:

<source>: In function 'int main()':

<source>:16:9: error: ambiguous overload for 'operator=' (operand types are
'std::pair<int, int>' and 'dummy')

     s = d;

         ^

In file included from
/opt/compiler-explorer/gcc-6.3.0/include/c++/6.3.0/utility:70:0,

                 from <source>:1:

/opt/compiler-explorer/gcc-6.3.0/include/c++/6.3.0/bits/stl_pair.h:359:7: note:
candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename
std::conditional<std::__and_<std::is_copy_assignable<_Tp>,
std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const
std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename
std::conditional<std::__and_<std::is_copy_assignable<_Tp>,
std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const
std::__nonesuch&>::type = const std::pair<int, int>&]

       operator=(typename conditional<

       ^~~~~~~~

/opt/compiler-explorer/gcc-6.3.0/include/c++/6.3.0/bits/stl_pair.h:370:7: note:
candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename
std::conditional<std::__not_<std::__and_<std::is_copy_assignable<_Tp>,
std::is_copy_assignable<_T2> > >::value, const std::pair<_T1, _T2>&, const
std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename
std::conditional<std::__not_<std::__and_<std::is_copy_assignable<_Tp>,
std::is_copy_assignable<_T2> > >::value, const std::pair<_T1, _T2>&, const
std::__nonesuch&>::type = const std::__nonesuch&] <deleted>

       operator=(typename conditional<

       ^~~~~~~~

/opt/compiler-explorer/gcc-6.3.0/include/c++/6.3.0/bits/stl_pair.h:376:7: note:
candidate: std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename
std::conditional<std::__and_<std::is_move_assignable<_Tp>,
std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&,
std::__nonesuch&&>::type) [with _T1 = int; _T2 = int; typename
std::conditional<std::__and_<std::is_move_assignable<_Tp>,
std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&,
std::__nonesuch&&>::type = std::pair<int, int>&&]

       operator=(typename conditional<

       ^~~~~~~~

Reply via email to