If you call vector erase() with an empty range, it invokes std::move() with an output iterator inside of the source range. (I.e. it tries to move all the elements onto themselves.) This causes problems if some of the elements don't support self move-assignment (e.g. if they are other std::vectors).
Ok, thanks, it's also an optimization.
deque too
Author: paolo Date: Tue Sep 27 02:39:34 2011 New Revision: 179234 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179234 Log: 2011-09-26 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/50529 * include/bits/vector.tcc (vector<>::erase(iterator, iterator)): Fix to do nothing if the range is empty. * include/bits/stl_bvector.h: Likewise. * include/bits/deque.tcc: Likewise. * include/debug/vector: Adjust. * include/debug/deque: Likewise. * testsuite/23_containers/vector/modifiers/erase/50529.cc: New. * testsuite/23_containers/deque/modifiers/erase/50529.cc: Likewise. * testsuite/23_containers/deque/modifiers/erase/3.cc: Adjust. Added: trunk/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc trunk/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/deque.tcc trunk/libstdc++-v3/include/bits/stl_bvector.h trunk/libstdc++-v3/include/bits/vector.tcc trunk/libstdc++-v3/include/debug/deque trunk/libstdc++-v3/include/debug/vector trunk/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc
Done.
Nice. Thanks!
Author: paolo Date: Fri Sep 30 20:47:12 2011 New Revision: 179403 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179403 Log: 2011-09-30 François Dumont <fdumont@gcc.gnu.org> * include/debug/vector (vector<>::erase(iterator, iterator)): Check iterators equality using normal iterators. * include/debug/deque (deque<>::erase(iterator, iterator)): Likewise. 2011-09-30 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/50529 * include/bits/vector.tcc (vector<>::erase(iterator, iterator)): Fix to do nothing if the range is empty. * include/bits/stl_bvector.h: Likewise. * include/bits/deque.tcc: Likewise. * include/debug/vector: Adjust. * include/debug/deque: Likewise. * testsuite/23_containers/vector/modifiers/erase/50529.cc: New. * testsuite/23_containers/deque/modifiers/erase/50529.cc: Likewise. * testsuite/23_containers/deque/modifiers/erase/3.cc: Adjust. Added: branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc Modified: branches/gcc-4_6-branch/libstdc++-v3/ChangeLog branches/gcc-4_6-branch/libstdc++-v3/include/bits/deque.tcc branches/gcc-4_6-branch/libstdc++-v3/include/bits/stl_bvector.h branches/gcc-4_6-branch/libstdc++-v3/include/bits/vector.tcc branches/gcc-4_6-branch/libstdc++-v3/include/debug/deque branches/gcc-4_6-branch/libstdc++-v3/include/debug/vector branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc
Fixed in 4.6.2 too.