digitalmars.D - Bug: toStringz with 16 char strings - test.d
- Evil Mr Henry <Evil_member pathlink.com> Jun 30 2004
- "Matthew" <admin stlsoft.dot.dot.dot.dot.org> Jun 30 2004
- "Dan Williams" <dnews ithium.NOSPAM.net> Jul 01 2004
- Arcane Jill <Arcane_member pathlink.com> Jul 01 2004
- "Walter" <newshound digitalmars.com> Jul 01 2004
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[].
Jun 30 2004
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[].
Jun 30 2004
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
string is 16 characters long, and includes a char[].
Jul 01 2004
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
Jul 01 2004
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
string is 16 characters long, and includes a char[].
Jul 01 2004









"Matthew" <admin stlsoft.dot.dot.dot.dot.org> 