Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
July 01, 2004 Bug: toStringz with 16 char strings - test.d | ||||
---|---|---|---|---|
| ||||
Attachments: | Linux, current compiler as of June 30. The following code: import std.string; void main() { char* num = "x"; char[] testName = std.string.toString(num); printf("%s\n", std.string.toStringz("1234567890123" ~ testName)); printf("%s\n", std.string.toStringz("12345678901234" ~ testName)); printf("%s\n", std.string.toStringz("123456789012345" ~ testName)); printf("%s\n", std.string.toStringz("1234567890123456" ~ testName)); printf("%s\n", std.string.toStringz("12345678901234567" ~ testName)); } will output: 1234567890123x 12345678901234x 123456789012345xÿ 1234567890123456x 12345678901234567x Notice the accented y? It shouldn't be there. This only occurs if the total string is 16 characters long, and includes a char[]. |
July 01, 2004 Re: toStringz with 16 char strings - test.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Evil Mr Henry | You should post this on the bugs NG "Evil Mr Henry" <Evil_member@pathlink.com> wrote in message news:cbvumd$2b9d$1@digitaldaemon.com... > Linux, current compiler as of June 30. The following code: > > import std.string; > void main() { > char* num = "x"; > char[] testName = std.string.toString(num); > printf("%s\n", std.string.toStringz("1234567890123" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234" ~ testName)); > printf("%s\n", std.string.toStringz("123456789012345" ~ testName)); > printf("%s\n", std.string.toStringz("1234567890123456" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234567" ~ testName)); > } > > will output: > 1234567890123x > 12345678901234x > 123456789012345xÿ > 1234567890123456x > 12345678901234567x > > Notice the accented y? It shouldn't be there. This only occurs if the total string is 16 characters long, and includes a char[]. > > > |
July 01, 2004 Re: toStringz with 16 char strings - test.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Evil Mr Henry | I cannot reproduce this bug. Using: DMD 0.9.4, RHEL 3.0, 2.4.21 kernel, GCC 3.2.3, can't think of anything else important Also tried on my WinXP system out of interest but no bug there either ;) My output on both systems is simply: 1234567890123x 12345678901234x 123456789012345x 1234567890123456x 12345678901234567x What Linux distro and version are you running, with what kernel, and what version of GCC? "Evil Mr Henry" <Evil_member@pathlink.com> wrote in message news:cbvumd$2b9d$1@digitaldaemon.com... > Linux, current compiler as of June 30. The following code: > > import std.string; > void main() { > char* num = "x"; > char[] testName = std.string.toString(num); > printf("%s\n", std.string.toStringz("1234567890123" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234" ~ testName)); > printf("%s\n", std.string.toStringz("123456789012345" ~ testName)); > printf("%s\n", std.string.toStringz("1234567890123456" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234567" ~ testName)); > } > > will output: > 1234567890123x > 12345678901234x > 123456789012345xÿ > 1234567890123456x > 12345678901234567x > > Notice the accented y? It shouldn't be there. This only occurs if the total > string is 16 characters long, and includes a char[]. > > > |
July 01, 2004 Re: Bug: toStringz with 16 char strings - test.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Evil Mr Henry | In article <cbvumd$2b9d$1@digitaldaemon.com>, Evil Mr Henry says... > >Notice the accented y? It shouldn't be there. This only occurs if the total string is 16 characters long, and includes a char[]. **** This bug is caused by a terminating uninitialized char **** Report it in the bugs newsgroup, and tell them the above. Meanwhile, I suggest you do what I did - go back to DMD 0.92. Arcane Jill |
July 01, 2004 Re: toStringz with 16 char strings - test.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Evil Mr Henry | This problem was corrected in 0.94, check the date on your copy of libphobos.a. "Evil Mr Henry" <Evil_member@pathlink.com> wrote in message news:cbvumd$2b9d$1@digitaldaemon.com... > Linux, current compiler as of June 30. The following code: > > import std.string; > void main() { > char* num = "x"; > char[] testName = std.string.toString(num); > printf("%s\n", std.string.toStringz("1234567890123" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234" ~ testName)); > printf("%s\n", std.string.toStringz("123456789012345" ~ testName)); > printf("%s\n", std.string.toStringz("1234567890123456" ~ testName)); > printf("%s\n", std.string.toStringz("12345678901234567" ~ testName)); > } > > will output: > 1234567890123x > 12345678901234x > 123456789012345xÿ > 1234567890123456x > 12345678901234567x > > Notice the accented y? It shouldn't be there. This only occurs if the total > string is 16 characters long, and includes a char[]. > > > |
Copyright © 1999-2021 by the D Language Foundation