[dmd-beta] dmd 1.062 and 2.047 beta

Walter Bright walter at digitalmars.com
Thu Jun 10 11:27:24 PDT 2010



Andrei Alexandrescu wrote:
> I can't reproduce the bug, code works for me with 2.047 on Linux. 
> Here's the relevant code:
>
> void writeln(T...)(T args)
> if (T.length == 1 && is(typeof(args[0]) : const(char)[]))
> {
>     enforce(fprintf(.stdout.p.handle, "%*s\n",
>         args[0].length, args[0].ptr) >= 0);
> }
>
> What is wrong with it?
>
>

The %*s should be %.*s

Also, the format will still stop anyway on encountering a 0 byte. Then, 
there's the overhead of fprintf itself. Better to just replace the thing 
with a call to fwrite:

enforce(fwrite(args[0].ptr, T.sizeof, args[0].length, .stdout.p.handle) 
== args[0].length);




More information about the dmd-beta mailing list