[Bug libstdc++/49559] stable_sort calls self-move-assignment operator
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 28 08:41:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49559
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.06.28 08:41:06
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-28 08:41:06 UTC ---
confirmed, __copy_move_b in stl_algobase.h performs the redundant self-move
this untested change fixes the testcase but I haven't checked if it's correct
or passes the testsuite:
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h (revision 175389)
+++ include/bits/stl_algobase.h (working copy)
@@ -541,8 +541,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static _BI2
__copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result)
{
- typename iterator_traits<_BI1>::difference_type __n;
- for (__n = __last - __first; __n > 0; --__n)
+ typename iterator_traits<_BI1>::difference_type __n
+ = __last - __first;
+ if (__n <= 1)
+ return __first;
+ for (; __n > 0; --__n)
*--__result = std::move(*--__last);
return __result;
}
More information about the Gcc-bugs
mailing list