[dmd-beta] dmd 1.062 and 2.047 beta

Steve Schveighoffer schveiguy at yahoo.com
Thu Jun 10 11:30:39 PDT 2010


One problem I see immediately that doesn't really affect correctness is that the argument is passed by value, so if you printed a large static char array, it would copy all the data in order to print it.

But I think the real problem is this.  From DMC++ docs:

If the field_width is the character *, the actual field_width value is taken from the next int arg. If the field_width is negative, it is treated as if the - flag were given and the absolute value of the field_width is used.

**** If there are more characters than allowed for by the field_width, then the width is expanded appropriately. ****

I think this means, the width passed is not the number of characters you want to print, but the *minimum* number of characters you want to print (with padding).

-Steve



----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
> To: Discuss the dmd beta releases for D <dmd-beta at puremagic.com>
> Cc: Richard Webb <richard.webb at boldonjames.com>
> Sent: Thu, June 10, 2010 2:08:00 PM
> Subject: Re: [dmd-beta] dmd 1.062 and 2.047 beta
> 
> 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?


Andrei

On 06/10/2010 07:45 AM, Richard Webb 
> wrote:
>
> Using 2.047 on Windows 2008, i see the 
> code
>
>     char[3] tmp = ['a', 'b', 'c'];
> 
>     writeln(tmp);
>
> print 
> abc<randombytes>  (in debug builds at least).
>
> 
> possibly because the change in
> 
> http://www.dsource.org/projects/phobos/changeset/1611 doesn't handle 
> non-null
> terminated character arrays?
>
>
> 
> _______________________________________________
> dmd-beta mailing 
> list
> 
> href="mailto:dmd-beta at puremagic.com">dmd-beta at puremagic.com
> 
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
_______________________________________________
dmd-beta 
> mailing list

> href="mailto:dmd-beta at puremagic.com">dmd-beta at puremagic.com

> href="http://lists.puremagic.com/mailman/listinfo/dmd-beta" target=_blank 
> >http://lists.puremagic.com/mailman/listinfo/dmd-beta


      


More information about the dmd-beta mailing list