http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59603
Bug ID: 59603 Summary: std::random_shuffle tries to swap element with itself Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fab at orlen dot de When using the debugging macro _GLIBCXX_DEBUG, calling random_shuffle fails on some types, because it might try to swap an element with itself. Output of attached program: /tmp$ g++ -o random_shuffle_bug -std=c++11 random_shuffle_bug.cc /tmp$ ./random_shuffle_bug /usr/include/c++/4.8.2/debug/vector:159:error: attempt to self move assign. Objects involved in the operation: sequence "this" @ 0x0xa600c8 { type = NSt7__debug6vectorIiSaIiEEE; } Aborted (core dumped) return code: 134 I could not find any information about whether swapping an element with itself is allowed.