-
Notifications
You must be signed in to change notification settings - Fork 11
IEEEReal.setRoundingMode is a no-op on Linux #70
Copy link
Copy link
Closed
Labels
basis-libproblem with Standard ML Basis libraryproblem with Standard ML Basis librarybugSomething isn't workingSomething isn't workingfixed-in-110.99.3issues that will be fixed in the 110.99.3 versionissues that will be fixed in the 110.99.3 versionfloating-pointproblem related to floating-point operationsproblem related to floating-point operationsgforgebug (or feature request) ported from smlnj-gforge repositorybug (or feature request) ported from smlnj-gforge repository
Metadata
Metadata
Assignees
Labels
basis-libproblem with Standard ML Basis libraryproblem with Standard ML Basis librarybugSomething isn't workingSomething isn't workingfixed-in-110.99.3issues that will be fixed in the 110.99.3 versionissues that will be fixed in the 110.99.3 versionfloating-pointproblem related to floating-point operationsproblem related to floating-point operationsgforgebug (or feature request) ported from smlnj-gforge repositorybug (or feature request) ported from smlnj-gforge repository
Version
v110.99.1
Operating System
OS Version
WSL
Processor
x86 (32-bit)
Component
Basis Library
Severity
Minor
Description of the problem
IEEEReal.setRoundingModeis a no-op and does not change the rounding mode.Additional comments:
This also causes issues the functions:
Real.realTrunc,Real.realCeil,Real.realFloor,Real.realRoundsince those functions are implemented in terms of
IEEEReal.setRoundingMode.Note that the default rounding mode is implementation-defined, so one and only one of these functions work properly.
Additionally, if
IEEEReal.setRoundingModeis unsupported, an error should be thrown instead of silently doing nothing,similar to other SML/NJ basis functions which are unimplemented (such as
Real.fromDecimal).Fix:
I was unable to understand how the runtime works,
but I think the C runtime may need to use the pragma
#pragma STDC FENV_ACCESS ON(http://www.cplusplus.com/reference/cfenv/FENV_ACCESS/)One temporary fix for
Real.realFloorwould be to implementrealFloor fas#whole (Real.split f).Transcript
Expected Behavior
No response
Steps to Reproduce
Additional Information
No response
Email address
ssoss@uchicago.edu
Comments from smlnj-gforge
Original smlnj-gforge bug number 314
Submitted via web form by Skye Soss ssoss@uchicago.edu on 2022-06-02 at 19:29:00
Keywords: reals, IEEEReal
comment by @JohnReppy on 2022-06-06 14:37:00 +000 UTC
This problem appears to be specific to Linux (e.g., things work correctly on macOS). It may be because compilers are allowed to ignore the floating-point environment unless the
FENV_ACCESSpragma is on.comment by @JohnReppy on 2022-06-06 15:17:00 +000 UTC
The problem turns out to be that Linux did not support the "fenv.h" API, so it was supposed to use assembly code. Modern Linux does have that include file, so we can just use the library functions.
Fixed for 110.99.3 and 2022.1.