[M3commit] [modula3/cm3] 640946: Fix bug compiling 16_8000000000000000 on 32-bit co...

GitHub noreply at github.com
Thu May 26 23:16:02 CEST 2016


  Branch: refs/heads/master
  Home:   https://github.com/modula3/cm3
  Commit: 64094695f6ece0914026729f93b9085297db1fa9
      https://github.com/modula3/cm3/commit/64094695f6ece0914026729f93b9085297db1fa9
  Author: Rodney Bates <rodney.m.bates at acm.org>
  Date:   2016-05-26 (Thu, 26 May 2016)

  Changed paths:
    M m3-sys/m3front/src/misc/TipeDesc.m3
    M m3-sys/m3middle/src/M3CG_BinWr.m3
    M m3-sys/m3middle/src/TInt.i3
    M m3-sys/m3middle/src/TInt.m3

  Log Message:
  -----------
  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 mailing list