digitalmars.D.bugs - [Issue 12889] New: std.algorithm remove is broken for arrays of arrays
- via Digitalmars-d-bugs (38/38) Jun 11 2014 https://issues.dlang.org/show_bug.cgi?id=12889
https://issues.dlang.org/show_bug.cgi?id=12889 Issue ID: 12889 Summary: std.algorithm remove is broken for arrays of arrays Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: Phobos Assignee: nobody puremagic.com Reporter: safety0ff.bugz gmail.com Trying to remove anything but the a single element from the front of a multidimensional array will cause a run time error. This causes bugs in phobos functions who depend on remove such as replaceInPlace. Code: import std.typecons; import std.algorithm; import std.stdio : writeln; void main() { // note: dimension doesn't matter int[1][] arr = [[0], [1], [2], [3], [4], [5], [6]]; size_t from = 1; // from is inclusive size_t to = 2; // to is exclusive //arr = remove(arr, tuple(from,to)); // object.Error: overlapping array copy //foreach (i; from .. to) arr = remove(arr, i); // object.Error: overlapping array copy arr = remove(arr, 0); // Ok! //arr = remove(arr, 1); // object.Error: overlapping array copy // even removing nothing is broken: //arr = remove(arr, tuple(0,0)); // object.Error: overlapping array copy writeln(arr); } --
Jun 11 2014