This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33807] New: Incorrect ambiguous overload
- From: "bldantes at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Oct 2007 06:37:35 -0000
- Subject: [Bug c++/33807] New: Incorrect ambiguous overload
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code fails to compile with an overload ambiguity in gcc 4.2.1. It
successfully compiles in 3.4.4, 4.0.3 and 4.1.1. In the error message, note
also the bogus display of the signature for the first candidate:
note: candidates are: bool std::operator!=(const std::allocator<_CharT>&, const
std::allocator<_T2>&) [with _T1 = std::_List_node<foo>, _T2 =
std::_List_node<foo>]
bug.cc
------
#include <list>
template <class T>
bool operator != (const T& x, const T& y) { return !(x == y); }
struct foo {};
void fnx() {
std::list<foo> l1, l2;
l1 = l2;
}
EOF
----
% g++ -c bug.cc
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/stl_list.h:
In member function 'void std::list<_Tp,
_Alloc>::_M_check_equal_allocators(std::list<_Tp, _Alloc>&) [with _Tp = foo,
_Alloc = std::allocator<foo>]':
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/stl_list.h:930:
instantiated from 'void std::list<_Tp,
_Alloc>::splice(std::_List_iterator<_Tp>, std::list<_Tp, _Alloc>&) [with _Tp =
foo, _Alloc = std::allocator<foo>]'
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/stl_list.h:833:
instantiated from 'void std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp>, _InputIterator, _InputIterator) [with
_InputIterator = std::_List_const_iterator<foo>, _Tp = foo, _Alloc =
std::allocator<foo>]'
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/list.tcc:135:
instantiated from 'std::list<_Tp, _Alloc>& std::list<_Tp,
_Alloc>::operator=(const std::list<_Tp, _Alloc>&) [with _Tp = foo, _Alloc =
std::allocator<foo>]'
bug.cc:9: instantiated from here
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/stl_list.h:1179:
error: ambiguous overload for 'operator!=' in '((std::list<foo,
std::allocator<foo> >*)this)->std::list<foo, std::allocator<foo>
>::<anonymous>.std::_List_base<_Tp, _Alloc>::_M_get_Node_allocator [with _Tp =
foo, _Alloc = std::allocator<foo>]() != ((std::list<foo, std::allocator<foo>
>*)__x)->std::list<foo, std::allocator<foo> >::<anonymous>.std::_List_base<_Tp,
_Alloc>::_M_get_Node_allocator [with _Tp = foo, _Alloc =
std::allocator<foo>]()'
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/bits/allocator.h:120:
note: candidates are: bool std::operator!=(const std::allocator<_CharT>&, const
std::allocator<_T2>&) [with _T1 = std::_List_node<foo>, _T2 =
std::_List_node<foo>]
/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.1/../../../../include/c++/4.2.1/ext/new_allocator.h:120:
note: bool __gnu_cxx::operator!=(const
__gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&) [with _Tp
= std::_List_node<foo>]
bug.cc:3: note: bool operator!=(const T&, const T&) [with T =
std::allocator<std::_List_node<foo> >]
Compilation exited abnormally with code 1 at Wed Oct 17 22:53:00
%
--
Summary: Incorrect ambiguous overload
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bldantes at comcast dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33807