Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#267] Returns an incorrect result for a calculation on Position.int for 32-bit mode.

Date:
2020-07-20 16:25
Priority:
3
State:
Closed
Submitted by:
takayuki goto (eldesh)
Assigned to:
John Reppy (jhr)
Machine Architecture:
x86
Operating System:
Linux
Component:
Compiler
Resolution:
Fixed
Severity:
Minor
OS Version:
SML/NJ Version:
110.98
Keywords:
arithmetic
URL:
Transcript (of reproduction):
Source (for reproduction):
$ sml -32 Standard ML of New Jersey (32-bit) v110.98 [built: Mon Jul 20 11:07:54 2020] - (Position.fromLarge ~0x8000000000000000) div (Position.fromLarge ~1); [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] val it = ~9223372036854775808 : ?.int64 -
Summary:
Returns an incorrect result for a calculation on Position.int for 32-bit mode.

Detailed description
Returns an incorrect result for the calculation on Position.int

sml(32bit) returns ~9223372036854775808 for the expression:

> (Position.fromLarge ~0x8000000000000000) div (Position.fromLarge ~1);

But in fact, ~9223372036854775808 is equal to ~0x8000000000000000.
There doesn't seem to be any calculations being made.

Comments:

Message  ↓
Date: 2020-12-19 15:41
Sender: John Reppy

The correct result is raising the Overflow exception. The problem was that on 32-bit machines, 64-bit division is implemented by the IntInf module with the result being converted to 64-bits. The conversion used did not test for overflow.

Fixed for 110.99

Attached Files:

Changes

Field Old Value Date By
summaryReturns an incorrect result for a calculation on Position.int for 32bit mode.2020-12-19 20:21jhr
status_idOpen2020-12-19 15:41jhr
close_dateNone2020-12-19 15:41jhr
ResolutionAccepted As Bug2020-12-19 15:41jhr
assigned_tonone2020-07-21 16:17jhr
Machine ArchitectureOther2020-07-21 16:17jhr
ResolutionNone2020-07-21 16:17jhr