[LLVMbugs] [Bug 16549] New: map<K, V>::insert(make_pair(K(), V())) is ambiguous if K has a template constructor
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 5 09:51:50 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16549
Bug ID: 16549
Summary: map<K,V>::insert(make_pair(K(), V())) is ambiguous if
K has a template constructor
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: release blocker
Priority: P
Component: All Bugs
Assignee: hhinnant at apple.com
Reporter: likan_999.student at sina.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Note: this is similar to the issue http://llvm.org/bugs/show_bug.cgi?id=16538,
but even after the fix r185665, the following code still fails.
Note: g++ 4.8.1 can compile it successfully.
Note: clang++ with libstdc++ can compile it successfully.
Note: the libc++ is at trunk version.
[hidden ~]$ cat b.cpp
#include <map>
#include <utility>
struct Key {
template <typename T> Key(const T&) {}
bool operator< (const Key&) const { return false; }
};
auto result = std::map<Key, int>().insert(std::make_pair(Key(0), 0));
[hidden ~]$ g++ -std=c++11 -c b.cpp
[hidden ~]$ clang++ -std=c++11 -c b.cpp
[hidden ~]$ clang++ -std=c++11 -stdlib=libc++ -c b.cpp
In file included from b.cpp:1:
In file included from /usr/include/c++/v1/map:371:
/usr/include/c++/v1/__tree:1604:17: error: call to object of type
'value_compare' (aka 'std::__1::__map_value_compare<Key, int,
std::__1::less<Key>, true>') is ambiguous
if (value_comp()(__v, __nd->__value_))
^~~~~~~~~~~~
/usr/include/c++/v1/__tree:1914:36: note: in instantiation of function template
specialization 'std::__1::__tree<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type,
std::__1::__map_value_compare<Key, int, std::__1::less<Key>, true>,
std::__1::allocator<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type>
>::__find_equal<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type>'
requested here
__node_base_pointer& __child = __find_equal(__parent, __nd->__value_);
^
/usr/include/c++/v1/__tree:1796:32: note: in instantiation of member function
'std::__1::__tree<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type,
std::__1::__map_value_compare<Key, int, std::__1::less<Key>, true>,
std::__1::allocator<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type>
>::__node_insert_unique'
requested here
pair<iterator, bool> __r = __node_insert_unique(__h.get());
^
/usr/include/c++/v1/map:916:29: note: in instantiation of function template
specialization 'std::__1::__tree<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type,
std::__1::__map_value_compare<Key, int, std::__1::less<Key>, true>,
std::__1::allocator<std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> > >::__value_type>
>::__insert_unique<std::__1::pair<Key, int> >' requested here
{return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
^
b.cpp:8:36: note: in instantiation of function template specialization
'std::__1::map<Key, int, std::__1::less<Key>,
std::__1::allocator<std::__1::pair<const Key, int> >
>::insert<std::__1::pair<Key, int>, void>' requested here
auto result = std::map<Key, int>().insert(std::make_pair(Key(0), 0));
^
/usr/include/c++/v1/map:405:10: note: candidate function
bool operator()(const _CP& __x, const _CP& __y) const
^
/usr/include/c++/v1/map:408:10: note: candidate function
bool operator()(const _CP& __x, const _Key& __y) const
^
/usr/include/c++/v1/map:411:10: note: candidate function
bool operator()(const _Key& __x, const _CP& __y) const
^
1 error generated.
--
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/20130705/bb49a7f8/attachment.html>
More information about the llvm-bugs
mailing list