Thread overview
toStringz with 16 char strings - test.d
Jul 01, 2004
Evil Mr Henry
Jul 01, 2004
Dan Williams
Jul 01, 2004
Arcane Jill
Jul 02, 2004
Walter
Jul 01, 2004
Ben Hinkle
July 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[].


July 01, 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:cc02p2$2hsb$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
In article <cc02p2$2hsb$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[].

How to fix this bug:
Explicitly initialize all chars.

Workaround:
Go back to DMD 0.92

Arcane Jill



July 01, 2004
are you sure you updated your libphobos.a to 0.94? It's easy to forget if you have to copy it to somewhere like /usr/lib

Evil Mr Henry wrote:

> 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 02, 2004
"Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:cc0tm9$rej$1@digitaldaemon.com...
> In article <cc02p2$2hsb$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[].
>
> How to fix this bug:
> Explicitly initialize all chars.
>
> Workaround:
> Go back to DMD 0.92

Except that 0.94 fixed the bug. <g>