When the spec says in https://dlang.org/spec/arrays.html, it demonstrates it using overlapping arrays, but only in the case of copying later elements (bigger index) to earlier elements (smaller index). In the case of the opposite direction, copy does not produce the expected result. The respective version of the example in the spec import std.algorithm; int[] s = [1, 2, 3, 4]; copy(s[0..2], s[1..3]); assert(s == [1, 1, 2, 4]); fails, because s == [1, 1, 1, 1].
@n8sh created dlang/phobos pull request #7879 "std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer" fixing this issue: - Fix Issue 21724 - std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer https://github.com/dlang/phobos/pull/7879
dlang/phobos pull request #7879 "std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer" was merged into stable: - b879f8a21c6b1c60cdd2e20134f5ca7632b41c47 by Nathan Sashihara: Fix Issue 21724 - std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer https://github.com/dlang/phobos/pull/7879
dlang/phobos pull request #7964 "merge stable" was merged into master: - edd9007c35f14f43e9d6203436d1f544f4337c9a by Nathan Sashihara: Fix Issue 21724 - std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer https://github.com/dlang/phobos/pull/7964
dlang/phobos pull request #8012 "merge stable" was merged into master: - d32131d952ebe6f87b7e191f20788a1a9cd9b723 by Nathan Sashihara: Fix Issue 21724 - std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer https://github.com/dlang/phobos/pull/8012