D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21724 - std.algorithm.mutation.copy fails on overlapping arrays if the source array's pointer is less than the destination array's pointer
Summary: std.algorithm.mutation.copy fails on overlapping arrays if the source array's...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-03-17 01:36 UTC by Bolpat
Modified: 2021-04-27 09:42 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bolpat 2021-03-17 01:36:24 UTC
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 Dlang Bot 2021-03-18 09:08:06 UTC
@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 Dlang Bot 2021-03-18 10:27:41 UTC
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 Dlang Bot 2021-04-25 13:46:03 UTC
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 Dlang Bot 2021-04-27 09:42:43 UTC
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