-
Notifications
You must be signed in to change notification settings - Fork 21
IEEEReal.setRoundingMode is a no-op on Linux #247
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-2022.1Issues that have been closed for the 2022.1 releaseIssues that have been closed for the 2022.1 releasefloating-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-2022.1Issues that have been closed for the 2022.1 releaseIssues that have been closed for the 2022.1 releasefloating-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
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
val it = () : unit
val it = TO_NEAREST : IEEEReal.rounding_mode
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-29-02 at 19:2900
Keywords: reals, IEEEReal
comment by @JohnReppy on 2022-37-06 14:3700 +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_ACCESS pragma is on.
comment by @JohnReppy on 2022-17-06 15:1700 +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.