[M3commit] [modula3/cm3] 640946: Fix bug compiling 16_8000000000000000 on 32-bit co...
noreply at github.com
Thu May 26 23:16:02 CEST 2016
Author: Rodney Bates <rodney.m.bates at acm.org>
Date: 2016-05-26 (Thu, 26 May 2016)
Fix bug compiling 16_8000000000000000 on 32-bit compile machine.
There was a mismatch in assumptions between TInt.ToBytes and its
callers. ToBytes treated its parameter as a TInt.T, a twos-complement
number stored in 9 bytes, so it can represent the overlap of 64-bit
signed and 64-bit unsigned values. It also treated its result
byte area as twos complement. Its callers are converting to
a sign-magnitude representation, and have already converted negative
values to absolute value. For this one value, this would require
9 bytes in twos-complement, but M3CG_BINWr.AddBigX only provides
8, which ToBytes, rightly, according to its assumptions, considers
insufficient to hold this number and returns zero.
Fixed by rewriting ToBytes with preconditioins that the value is
nonnegative and fits in the given number of result bytes, but does
not need a sign bit, since it is implicitly positive. Rename this
ToUnsignedBytes, to be less likely to fool future potential callers.
More information about the M3commit