[Bug libstdc++/43917] [C++0x] std::swap not working

2010-04-28 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-28 09:07 ---
*** Bug 43916 has been marked as a duplicate of this bug. ***


-- 


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



[Bug libstdc++/43917] [C++0x] std::swap not working

2010-04-28 Thread paolo dot carlini at oracle dot com


--- Comment #2 from paolo dot carlini at oracle dot com  2010-04-28 09:09 
---
Likely, something is broken in your installation, this problem cannot be
reproduced in a sane installation of 4.5.0 or mainline. Note that the std::swap
overload for std::pair takes *lvalue* references.


-- 

paolo dot carlini at oracle dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||WORKSFORME


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



[Bug libstdc++/43917] [C++0x] std::swap not working

2010-04-28 Thread navin dot kumar at gmail dot com


--- Comment #3 from navin dot kumar at gmail dot com  2010-04-28 17:43 
---
Are you compiling with -std=c++0x or without?  It compiles fine without the
-std=c++0x flag.  The issue is when it is supplied.

Look at line 134 of include/c++/4.5.0/bits/stl_pair.h; inside a #ifdef
__GXX_EXPERIMENTAL_CXX0X__ tag there is the following function:

  void
  swap(pair __p)
  {
using std::swap;
swap(first, __p.first);
swap(second, __p.second);   
  }

The compiler error stems from trying to pass a pair l-value reference to
pair.

Here's the compiler error with line numbers:
include/c++/4.5.0/bits/stl_pair.h: In function ‘void std::swap(std::pair_T1,
_T2, std::pair_T1, _T2) [with _T1 = std::basic_stringchar, _T2 =
std::basic_stringchar]’:
test.cpp:8:19:   instantiated from here
include/c++/4.5.0/bits/stl_pair.h:187:7: error: cannot bind
‘std::pairstd::basic_stringchar, std::basic_stringchar ’ lvalue to
‘std::pairstd::basic_stringchar, std::basic_stringchar ’
include/c++/4.5.0/bits/stl_pair.h:134:7: error:   initializing argument 1 of
‘void std::pair_T1, _T2::swap(std::pair_T1, _T2) [with _T1 =
std::basic_stringchar, _T2 = std::basic_stringchar, std::pair_T1, _T2 =
std::pairstd::basic_stringchar, std::basic_stringchar ]’


-- 

navin dot kumar at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|WORKSFORME  |


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



[Bug libstdc++/43917] [C++0x] std::swap not working

2010-04-28 Thread redi at gcc dot gnu dot org


--- Comment #4 from redi at gcc dot gnu dot org  2010-04-28 18:40 ---
No, that's not what pair::swap looks like in 4.5.0, your installation is
broken. This is what I have in 4.5.0

  void
  swap(pair __p)
  {
using std::swap;
swap(first, __p.first);
swap(second, __p.second);
  }

Somehow you have a header from 4.4 in your 4.5 tree, or you have been manually
messing with headers


-- 

redi at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||WORKSFORME


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