https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59603
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jörg Richter from comment #2) > Seems like we have hit this bug too. It happens not only in debug mode. We > have a testcase that triggers valgrind errors in non-debug mode while > calling random_shuffle. I can try to reduce this testcase if it would help. Would you be able to provide such a test? self-move in non-debug mode should not cause valgrind errors, it should just cause the vector to be left empty (so the valgrind errors might come later if you assume the vector still contains data and try to access it).