Bug 21724 – std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-17T01:36:24Z
Last change time
2021-04-27T09:42:43Z
Keywords
pull
Assigned to
No Owner
Creator
Bolpat

Comments

Comment #0 by qs.il.paperinik — 2021-03-17T01:36:24Z
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].
Comment #1 by dlang-bot — 2021-03-18T09:08:06Z
@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
Comment #2 by dlang-bot — 2021-03-18T10:27:41Z
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
Comment #3 by dlang-bot — 2021-04-25T13:46:03Z
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
Comment #4 by dlang-bot — 2021-04-27T09:42:43Z
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