digitalmars.D - Bug: toStringz with 16 char strings - test.d
- Evil Mr Henry (32/32) Jun 30 2004 Linux, current compiler as of June 30. The following code:
 - Matthew (3/22) Jun 30 2004 You should post this on the bugs NG
 - Dan Williams (15/34) Jul 01 2004 I cannot reproduce this bug.
 - Arcane Jill (5/7) Jul 01 2004 **** This bug is caused by a terminating uninitialized char ****
 - Walter (5/24) Jul 01 2004 This problem was corrected in 0.94, check the date on your copy of
 
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[].
begin 0644 test.d
M:6UP;W)T('-T9"YS=')I;F<[" IV;VED(&UA:6XH*2!["F-H87(J(&YU;2`]
M(")X(CL*8VAA<EM=('1E<W1.86UE(#T <W1D+G-T<FEN9RYT;U-T<FEN9RAN
M=6TI.PIP<FEN=&8H(B5S7&XB+"!S=&0N<W1R:6YG+G1O4W1R:6YG>B B,3(S
M*3L*<')I;G1F*"(E<UQN(BP <W1D+G-T<FEN9RYT;U-T<FEN9WHH(C$R,S0U
M-C<X.3`Q,C,T-2( ?B!T97-T3F%M92DI.PIP<FEN=&8H(B5S7&XB+"!S=&0N
M92DI.PIP<FEN=&8H(B5S7&XB+"!S=&0N<W1R:6YG+G1O4W1R:6YG>B B,3(S
`
end
 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 thetotalstring 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 thetotalstring is 16 characters long, and includes a char[].
 Jul 01 2004








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