std.compress

David Nadlinger code at klickverbot.at
Fri Jun 7 06:47:58 PDT 2013


On Friday, 7 June 2013 at 07:42:15 UTC, Peter Alexander wrote:
> On Thursday, 6 June 2013 at 20:50:08 UTC, David Nadlinger wrote:
>> On Wednesday, 5 June 2013 at 20:49:19 UTC, Walter Bright wrote:
>>>> uses C printf (!) in the examples,
>>>
>>> Again, trying to make it lightweight.
>>
>> … and wrong, in more than one way.
>>
>> David
>>
>>
>> (What happens if the input is larger than 'uint.max / 2 + 1'? 
>> Than 'uint.max' on a 'size_t.sizeof == 8' target?)
>
> Not sure what you're getting at. I can only see 2 uncommented 
> calls to printf, and neither do any formatting, so I'm not sure 
> how they'd be wrong?

'%d' isn't the correct format specifier for size_t. The code will 
still run on 64 bit systems (at least with the common ABIs out 
there), but print wrong values for long inputs.

Using an API that is known to be error-prone even in the C world 
simply has no place in the Phobos documentation.

David


More information about the Digitalmars-d mailing list