'int' is enough for 'length' to migrate code from x86 to x64

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 19 10:16:32 PST 2014


On 11/19/14, 10:21 AM, ketmar via Digitalmars-d wrote:
> On Wed, 19 Nov 2014 10:03:34 +0000
> Don via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>
>> No! No! No!  This is completely wrong. Unsigned does not mean
>> "positive". It means "no sign", and therefore "wrapping
>> semantics".
>> eg length - 4 > 0, if length is 2.
>>
>> Weird consequence: using subtraction with an unsigned type is
>> nearly always a bug.
> negative length is a bug too.

How is that a bug? Can you provide some code that exhibits this?



More information about the Digitalmars-d mailing list