On 6/23/15 10:20 AM, Baz wrote:
On Tuesday, 23 June 2015 at 13:29:41 UTC, Steven Schveighoffer wrote:
On 6/23/15 8:12 AM, Baz wrote:
On Tuesday, 23 June 2015 at 11:22:31 UTC, Steven Schveighoffer wrote:
[...]

according to the C library, memmove handle overlapps, you mismatch with
memcpy which does not.


The above is not memmove, it's slice assignment, which is specifically
illegal for overlaps:

$ cat testsliceassign.d
void buffer[100];

void main()
{
    buffer[1..$] = buffer[0..$-1];
}

$ dmd testsliceassign.d
$ ./testsliceassign
object.Error@(0): Overlapping arrays in copy: 98 byte(s) overlap of 99


ok. i was, wrongly, suposing that this operation uses memmove under the
hood.
btw you forgot to grow the array size, if i dare.

Heh, it was just to demonstrate the error :) The code does a whole lot of nothing, actually.

-Steve

Reply via email to