http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48038
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2011.03.09 11:11:23 CC| |paolo.carlini at oracle dot | |com Summary|stable_sort problem with |[C++0x] stable_sort problem |C++0x and comparator by |with C++0x and comparator |value |by value Ever Confirmed|0 |1 --- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-09 11:11:23 UTC --- #include <algorithm> #include <assert.h> struct V { int val; bool ok; V(int v) : val(v), ok(true) { } V(V const & rh) : val(rh.val), ok(rh.ok) { assert(rh.ok); } V & operator=(V const &rh) { assert(rh.ok); val = rh.val; ok = rh.ok; return *this; } V(V && rh) : val(rh.val), ok(rh.ok) { assert(rh.ok); rh.ok = false; } V & operator=(V && rh) { assert(rh.ok); val = rh.val; rh.ok = false; return *this; } }; inline bool operator<(V lh, V rh) { assert(rh.ok); assert(lh.ok); return lh.val < rh.val; } int main() { V vvs[] = { 2, 0 }; std::stable_sort(vvs, vvs+2); } The first element has ok=false after constructing the Temporary_buffer in std::stable_sort, because __uninitialized_construct_buf_dispatch::__ucr uses _GLIBCXX_MOVE which leaves vvs[0] in a moved-from state Paolo, could you take a look?