This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/48038] [C++0x] stable_sort problem with C++0x and comparator by value
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 9 Mar 2011 13:35:02 +0000
- Subject: [Bug libstdc++/48038] [C++0x] stable_sort problem with C++0x and comparator by value
- Auto-submitted: auto-generated
- References: <bug-48038-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48038
--- Comment #18 from Chris Jefferson <chris at bubblescope dot net> 2011-03-09 13:34:51 UTC ---
Just to update:
I have checked other users of MOVE_ITERATOR (there are only two) and they
appear fine, as they do not use a comparator.
Attached is an initial patch. Very sorry if the formatting (particular tabs)
are off, I am using a different texteditor to normal and am having trouble
configuring correctly.
This patch might look quite long but it is actually fairly minimal.
Basically we introduce methods __move_merge_backward and __move_merge, which
act similarly to merge but move values. We call the comparitor methods without
any moving, so they behave themselves.
__merge_backward was only ever used with arguments that move, so I have renamed
it to __move_merge_backward for clarity and changed the places it is called.
Also introduce __move_merge which is identical to std::merge, except it moves
values into place rather than copies them.
Then fix all places which call merge or __merge_backward with MOVE_ITERATORS to
use the new methods.
Finally, there is a little testcase.
As a sanity check, I would like to make sure that other types (the other sorts
being the obvious target) also work correctly. I can't imagine why they
wouldn't, but I'm very suprised this broke!