dmd 1.046 and 2.031 releases

Denis Koroskin 2korden at gmail.com
Mon Jul 6 05:21:18 PDT 2009


On Mon, 06 Jul 2009 14:28:38 +0400, Walter Bright
<newshound1 at digitalmars.com> wrote:

> Denis Koroskin wrote:
>>> auto x = p1 - p2;
>>>
>>> What's the type of x?
>>  ptrdiff_t, signed counterpart of size_t
>
> Do you really want an error if you go:
>
> size_t y = p1 - p2;
>
> ?
>

Of course, what sense does it make when p2 > p1?

I'd put an assert and made a cast explicit, if a size_t is so badly needed  
for ptr difference:

assert(p1 >= p2);
size_t y = cast(size_t)p1 - p2;


More information about the Digitalmars-d-announce mailing list