https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90934
Bug ID: 90934 Summary: std::vector self-move-insert bug Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ndkrempel at gmail dot com Target Milestone: --- Inserting into a vector with an rvalue reference to an item already in the vector produces incorrect results (specifically when inserting prior to the existing location and when a resize is *not* required): #include <iostream> #include <utility> #include <vector> int main() { std::vector<int> v{1, 2}; v.reserve(3); v.insert(v.begin(), std::move(v.back())); for (auto x : v) { std::cout << x << std::endl; } } This outputs "1 1 2" instead of "2 1 2". Removing either the "reserve" or the "std::move" gives the correct result. (https://wandbox.org/permlink/qeBMggNmvISHlPIx)