June 10, 2010
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
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
June 10, 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);


June 10, 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



June 10, 2010
On 06/10/2010 01:27 PM, Walter Bright wrote:
> The %*s should be %.*s

Fixed. Please svn up.

> 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);

I need to print an \n too, and atomically at that.


Andrei
June 10, 2010
On 10/06/10 03:10, Walter Bright wrote:
>
> http://ftp.digitalmars.com/dmd1beta.zip http://ftp.digitalmars.com/dmd2beta.zip

You must be doing something right Walter, all the problems so far have been with phobos rather than dmd, even with the huge (far greater than normal) list of changes... Thank you and congrats!

Robert

PS: Obviously less importantly, my code seems to be working with these releases ;)

June 10, 2010
On 10 June 2010 18:58, Walter Bright <walter at digitalmars.com> wrote:
>
>
> Don Clugston wrote:
>>
>> I wish we'd get rid of them entirely. They don't add any value at all. The only thing that's relevant is D1 only, D2 only, D1+D2.
>>
>>
>
> I added those.

Thanks! That'll help a lot.
June 10, 2010
And the concrete version numbers?  You mean you were in there adding stuff, and you didn't add those?!

Those new version numbers are going to be as useless as 'future' BTW, since you can't definitively search based on them.  D1/D2 should be a separate field from version.

-Steve



----- Original Message ----
> From: Walter Bright <walter at digitalmars.com>
> To: Discuss the dmd beta releases for D <dmd-beta at puremagic.com>
> Sent: Thu, June 10, 2010 12:58:56 PM
> Subject: Re: [dmd-beta] dmd 1.062 and 2.047 beta
> 
> 

Don Clugston wrote:
>
> I wish we'd get rid of them
> entirely. They don't add any value at all.
> The only thing that's
> relevant is D1 only, D2 only, D1+D2.
>
> 

I added
> those.
_______________________________________________
dmd-beta mailing
> list

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



June 10, 2010
On 10 June 2010 18:07, Steve Schveighoffer <schveiguy at yahoo.com> wrote:
> ----- Original Message ----
>> From: Don Clugston <dclugston at googlemail.com>
>
>> That's untrue, for
>> three reasons. Firstly, and most importantly, the version information is
>> indicated by the date the bug was filed; people are almost always using the
>> latest version.
>
> The date filed is not nearly as useful as the version. ?Quick, compile the code with dmd circa 5/24! ?Your assumption is very wrong, people don't use the latest version often because a) it's easier not to update your code whenever a new version comes out that doesn't interest them (new features don't affect them, or bugs fixed don't affect them) or b) the newest version has some other bug that makes it unable to compile/use their code.

It really doesn't work like that. Most bugs persist for a very long
time, and are easy to reproduce.
Are your comments based on experience with finding them helpful? My
experience after looking at many hundreds of bugs is that the version
numbers are not useful at all. Really not.
June 10, 2010

Steve Schveighoffer wrote:
> And the concrete version numbers?  You mean you were in there adding stuff, and you didn't add those?!
> 

Right. I think Don made a pretty good case. One thing he didn't mention is that there are too many version numbers, adding two more each month makes the list completely impractical sooner or later.

> Those new version numbers are going to be as useless as 'future' BTW, since you can't definitively search based on them.  D1/D2 should be a separate field from version.
>
> -Steve
>
> 
June 10, 2010



----- Original Message ----
> From: Walter Bright <walter at digitalmars.com>
> Right. I think Don made a pretty good case. One
> thing he didn't mention
> is that there are too many version numbers, adding
> two more each month
> makes the list completely impractical sooner or
> later.

impractical how?  I can manage it just fine.  If I want to find all D2 bugs, I just select the first D2 version, then shift click the last version.  It takes all of 5 seconds.

What's happening now is, people are selecting 'future', or I guess now they will select 'D2', and then report their compiler/phobos version in the report text, which is much harder to search for.

How would I search for bugs reported before or since some version?  Going by date doesn't work, as I've said before.  People do not update their compilers often, as the process is somewhat of a pain.

I don't know what the resistance is to having more information...  Do others besides Don and you feel the version numbers have no value?  Namely, I'm asking phobos developers who fix bugs, not dmd developers.

-Steve