[Bug libstdc++/57619] New: std::unordered_map and std::unordered_multimap::insert invoking std::pair move constructor
gdjss2728 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 14 21:41:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57619
Bug ID: 57619
Summary: std::unordered_map and std::unordered_multimap::insert
invoking std::pair move constructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: gdjss2728 at gmail dot com
The following code is invoking the std::pair move constructor:
int main ()
{
std::unordered_map<std::string, std::string> mymap;
std::unordered_multimap<std::string, std::string> mymultimap;
std::pair<std::string, std::string> mypair{std::string("key"),
std::string("value")};
mymultimap.insert(mypair); // std::pair move constructor invoked here
mymap.insert(mypair); // strings already moved out!
}
This seems related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53657.
As far as I can tell, overload resolution is choosing `insert(_Pair&& __x)`
over `insert(const value_type& __x)`. Since this is an lvalue, the latter
should be chosen. This happens for std::unordered_map::insert and
std::unordered_multimap::insert.
More information about the Gcc-bugs
mailing list