[Bug libstdc++/57619] New: std::unordered_map and std::unordered_multimap::insert invoking std::pair move constructor

2013-06-14 Thread gdjss2728 at gmail dot com
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_mapstd::string, std::string mymap;
std::unordered_multimapstd::string, std::string mymultimap;
std::pairstd::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.


[Bug c++/56701] New: The *this* pointer fails to bind to rvalue reference to pointer type

2013-03-23 Thread gdjss2728 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56701



 Bug #: 56701

   Summary: The *this* pointer fails to bind to rvalue reference

to pointer type

Classification: Unclassified

   Product: gcc

   Version: 4.8.0

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c++

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: gdjss2...@gmail.com





The following fails to compile with gcc 4.8.0:



struct A

{

  void f(){ A* a = this; }

};

int main(){}



Error messages:

error: invalid initialization of reference of type 'A*' from expression of

type 'A* const'

void f(){ A* a = this; }





According to 9.3.2p1, the this pointer is a prvalue of type A*, not A* const as

the error message suggests.