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

[#213] Int32.div raises Div instead of Overflow one dividing minInt by ~1

Date:
2018-05-28 14:18
Priority:
3
State:
Open
Submitted by:
John Reppy (jhr)
Assigned to:
John Reppy (jhr)
Machine Architecture:
x86
Operating System:
All
Component:
Compiler
Resolution:
Accepted As Bug
Severity:
Minor
OS Version:
SML/NJ Version:
110.82
Keywords:
integer division
URL:
Transcript (of reproduction):
Standard ML of New Jersey v110.82 [built: Sat Oct 14 13:08:58 2017] - Int.div(valOf Int.minInt, ~1); [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] uncaught exception Overflow [overflow] raised at: <file stdIn> - Int32.div(valOf Int32.minInt, ~1); [autoloading] [autoloading done] uncaught exception Div [divide by zero] raised at: <file stdIn> - Int32.~(valOf Int32.minInt); uncaught exception Overflow [overflow] raised at: <file stdIn> - Int32.quot(valOf Int32.minInt, ~1); uncaught exception Div [divide by zero] raised at: <file stdIn>
Source (for reproduction):
Int.div(valOf Int.minInt, ~1); Int32.div(valOf Int32.minInt, ~1); Int32.~(valOf Int32.minInt); Int32.quot(valOf Int32.minInt, ~1);
Summary:
Int32.div raises Div instead of Overflow one dividing minInt by ~1

Detailed description
According to the Basis Library specification, dividing the largest negative number by ~1 should result in an Overflow exception (since the result is too large). The compiler's behavior is correct for 31-bit tagged integers (because the overflow is detected when the untagged result is converted to a tagged result), but is not correct for 32-bit integers. This bug is likely present on other architectures.

This bug is bug numbers 1388 and 1509 in the old bug list.

Comments:

No Comments Have Been Posted

Attached Files:

Changes

No Changes Have Been Made to This Item