[Vm-dev] Fwd: absolute value of an unsigned

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sat Oct 24 00:10:07 UTC 2015


Oups wrong list

---------- Forwarded message ----------
From: Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Date: 2015-10-24 1:57 GMT+02:00
Subject: absolute value of an unsigned
To: vm-dev-request at lists.squeakfoundation.org



In smalltalk (a - b) abs allways makes sense...
But if ever one of the variables is translated unsigned, then C code

abs(a-b) means something else...
It means (a-b) \\ 16rFFFFFFFF

It should be abs((signed)(a-b)) in 32 bits (or sqInt...)

Plus the problem of abs behind defined int abs(int) (see labs post above),
I strongly believe it's urgent to let

CCodeGenerator>>initializeCTranslationDictionary
...
    pairs := #(
    #&                #generateAbs:on:indent:

and CCodeGenerator>>generateAnd:on:indent: correctly infer types and
introduce long abs and signed cast when due.

Example of potentially wrongly generated code: shrinkObjectMemory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20151024/2fb1b9cf/attachment.htm


More information about the Vm-dev mailing list