Portability bug in integral conversion

Walter Bright newshound2 at digitalmars.com
Mon Jan 17 12:30:44 PST 2011


bearophile wrote:
> Walter:
> 
>> Look at the asm dump of a function. It's full of add's - not only ADD 
>> instructions, but addressing mode multiplies and add's. Subtraction is
>> often expressed in terms of addition, relying on twos-complement
>> wraparound.
> 
> This answer is a bit relevant only if the programmer is using inline asm,
> while the discussion was about unsigned differences in D code, that are
> uncommon in my D code. Sometimes I even assign lengths to signed-word
> variables, to avoid some signed/unsigned comparison bugs.

A lot of the addition is also carried out at link time, and even by the loader. 
Subtraction is done by relying on overflow.


More information about the Digitalmars-d mailing list