[Issue 2418] Same-value string (char[]) literals get overwritten (unlike array literals)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 14 15:59:20 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2418
------- Comment #1 from business3 at twistedpairgaming.com 2008-10-14 17:59 -------
Sorry, I guess those classes are not needed:
---------------
module test;
import tango.io.Stdout;
void main()
{
char[] a;
char[] b;
char[] c;
char[] d;
a = "AAA";
Stdout.formatln("a: {}", a);
a[0] = '!';
Stdout.formatln("a: {}", a);
a = "AAA";
Stdout.formatln("a: {}", a);
Stdout.formatln("");
b = "AAA";
Stdout.formatln("b: {}", b);
b[0] = '!';
Stdout.formatln("b: {}", b);
b = "AAA";
Stdout.formatln("b: {}", b);
Stdout.formatln("");
c = "AA1";
Stdout.formatln("c: {}", c);
c[0] = '!';
Stdout.formatln("c: {}", c);
c = "AA1";
Stdout.formatln("c: {}", c);
Stdout.formatln("");
const char[] dInit = "AA2";
d = dInit;
Stdout.formatln("d: {}", d);
d[0] = '!';
Stdout.formatln("d: {}", d);
d = dInit;
Stdout.formatln("d: {}", d);
Stdout.formatln("");
int[] i;
i = [1, 2];
Stdout.formatln("i: {}", i);
i[0] = 77;
Stdout.formatln("i: {}", i);
i = [1, 2];
Stdout.formatln("i: {}", i);
}
---------------
Expected output:
a: AAA
a: !AA
a: AAA
b: AAA
b: !AA
b: AAA
c: AA1
c: !A1
c: AA1
d: AA2
d: !A2
d: AA2
i: [1, 2]
i: [77, 2]
i: [1, 2]
Actual output:
a: AAA
a: !AA
a: !AA
b: !AA
b: !AA
b: !AA
c: AA1
c: !A1
c: !A1
d: AA2
d: !A2
d: !A2
i: [1, 2]
i: [77, 2]
i: [1, 2]
--
More information about the Digitalmars-d-bugs
mailing list