January 28, 2007 Re: DMD 1.004 release | ||||
---|---|---|---|---|
| ||||
Derek Parnell Wrote:
> On Sat, 27 Jan 2007 16:35:23 -0500, Jordan Miner wrote:
>
> > Here is a problem I've found in post-1.00 versions.
> > I have this unittest in my library:
> >
> > unittest {
> > char[] c = "Computer";
> > ArrayCopy!(char)(c, 3, c, 2, 4);
> > assert(c == "Coputeer");
> > c = "Computer";
> > ArrayCopy!(char)(c, 2, c, 3, 4);
> > assert(c == "Commputr");
> > }
>
> Does this work for you?
>
> unittest {
> char[] c = "Computer".dup; // Take a copy of the string literal.
> ArrayCopy!(char)(c, 3, c, 2, 4);
> assert(c == "Coputeer");
> c = "Computer";
> ArrayCopy!(char)(c, 2, c, 3, 4);
> assert(c == "Commputr");
> }
>
>
> I suspect that you are trying to (inadvertantly) modify a string literal.
>
> --
> Derek Parnell
Yes, I've fixed it now by putting a .dup on the literal both times before assigning it to c.
|
Copyright © 1999-2021 by the D Language Foundation