[M3commit] CVS Update: cm3
Rodney M. Bates
rodney.bates at wichita.edu
Fri Apr 11 18:37:56 CEST 2008
Tony Hosking wrote:
> I am tracking down this bug right now (trying to get a 64-bit
> AMD64_DARWIN port) up and running. If you have something as a testcase
> that will demonstrate the problem I would appreciate it.
Attached. It doesn't write any output. I just used m3gdb to go in and
print variables at various times. Line 16 is enough to show the problem.
I also used m3cgcat, where the problem also shows.
Where things go wrong is in TInt.ToInt, line 65:
PROCEDURE ToInt (READONLY r: Int; VAR x: INTEGER): BOOLEAN =
VAR sign := CheckSign (r, BITSIZE (INTEGER) DIV BITSIZE (IByte)); (* <=== line 65, HERE. *)
BEGIN
(* ensure the result has the right sign extension *)
CASE sign OF
| Sign.Bad => RETURN FALSE;
| Sign.Pos => x := 0;
| Sign.Neg => x := Word.Not (0);
END;
(* finally, pack the bits *)
FOR i := r.n-1 TO 0 BY -1 DO
x := Word.Or (LShift (x, BITSIZE (IByte)), r.x[i]);
END;
RETURN TRUE;
END ToInt;
The value gets through all the stages OK to here, with r.n=8, but the 2nd
actual parameter to CheckSign is 4, and CheckSign thinks the value is
negative and within the range of INTEGER. I think just passing r.n to
CheckSign would be right, but there are lots of calls on ToInt that I
haven't looked at, so for a quick fix, I did the hack at the relevant call
site in M3CG_BinWr.
>
> On Apr 11, 2008, at 5:08 PM, Rodney M. Bates wrote:
>
>> CVSROOT: /usr/cvs
>> Changes by: rodney at birch. 08/04/11 17:08:38
>>
>> Modified files:
>> cm3/m3-sys/m3middle/src/: M3CG_BinWr.m3
>>
>> Log message:
>> Fix a bug that caused, e.g., 16_80000000L and 16_000000008000000L
>> to be converted to 16_ffffffff8000000L. This is something of a
>> low hack at a call site on TInt.ToInt. Probably, the fix should
>> be pushed inside TInt.ToInt, but all the calls thereon need to be
>> reviewed before doing this.
>
>
>
--
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: LongintArith.m3
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20080411/c7999b63/attachment-0002.ksh>
More information about the M3commit
mailing list