www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.array transition question + bug question

reply "safety0ff" <safety0ff.dev gmail.com> writes:
Hello,
I was replacing some nasty slice code with std.array calls when I 
encountered the following situation:

void main()
{   import std.array, std.stdio;
     int[2][] arr = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 
0], [6, 0]];
     size_t from = 4;  // from is inclusive
     size_t to = 6;    // to is exclusive
     int[2][] stuff = [[0, 0], [1, 0]]; // data in arr & stuff is 
irrelevant
     replaceInPlace(arr,from,to,stuff); // object.Error: 
overlapping array copy
     writeln(arr);     // http://dpaste.dzfl.pl/40de0689e747
}
When 'from' and 'to' differ by one, there's no error, when two or 
greater, error.
I believe it is a bug, but want confirmation.

When I took a peek at std.array code on github I found:

https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L1921
and:
https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L2076

I was wondering what was the status on this transition.
The code has been commented out in there for over 3 years.

Thanks!

P.S. I'd normally post this to D.learn, but I thought the 
question about the commented out code warranted a bump to D main 
newsgroup.
Jun 10 2014
next sibling parent "safety0ff" <safety0ff.dev gmail.com> writes:
On Wednesday, 11 June 2014 at 06:40:24 UTC, safety0ff wrote:
 When 'from' and 'to' differ by one, there's no error, when two 
 or greater, error.
 I believe it is a bug, but want confirmation.

Actually, it seems that the trigger is 'to - from' being equal to 'stuff.length'.
Jun 10 2014
prev sibling next sibling parent Jonathan M Davis via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Wed, 11 Jun 2014 06:40:23 +0000
safety0ff via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 When I took a peek at std.array code on github I found:

 https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L1921
 and:
 https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L2076

It should have been uncommented out ages ago, but it was never done. So, we need to uncomment it out and make sure that it still works, in which case, presumably it can be added in like it was supposed to be. - Jonathan M Davis
Jun 11 2014
prev sibling parent "safety0ff" <safety0ff.dev gmail.com> writes:
On Wednesday, 11 June 2014 at 07:56:12 UTC, Jonathan M Davis via 
Digitalmars-d wrote:
 It should have been uncommented out ages ago, but it was never 
 done. So, we
 need to uncomment it out and make sure that it still works, in 
 which case,
 presumably it can be added in like it was supposed to be.

 - Jonathan M Davis

Ok, filed as bug: https://issues.dlang.org/show_bug.cgi?id=12889 and enhancement. https://issues.dlang.org/show_bug.cgi?id=12890
Jun 11 2014