-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should we handle fenv? #480
Comments
Related question: are there more uses rounding modes? I only know of result bracketing. |
As Rust doesn't support non-default fenv, there's no way to support using a non-default fenv from the If having a way to use different rounding modes and check floating point exceptions via the Rust crate is desired, libm could have functions like If adding support for takes-rounding-mode-and-also-returns-exceptions functions is decided not to be worthwhile, and having untested code is to be avoided, I'd suggest just removing the fenv handling, leaving a comment in it's place mentioning you've done so. The original implementation can always be referenced if fenv-handling is needed in the future. |
Yes, rustc emits LLVM IR that uses the default floating point environment and as long as that's the case, querying/modifying the dynamic rounding mode or even querying exception status is effectively Undefined Behavior. Trying to change the codegen (even for a limited, nightly-only feature) runs into a lot of hard language design issues very quickly, and trying to tip-toe around it is extremely difficult as @beetrees described, so I would also suggest not bothering at all. Looking at the history of |
I am not entirely sure how we should or shouldn't be handling and testing fenv. It would be nice to comply with what the C specification says, but on the other hand I am unsure if it makes much sense considering RFC3514 says Rust does not support fenv and, as I understand it, LLVM still does not fully support it (though my information may be out of date here).
On one hand it would be nice to just remove everything that handles rounding modes and exceptions in order to keep code cleaner. On the other hand we are beginning to port some high quality algorithms that do correctly handle rounding modes, so I am leaning toward figuring out some way to test this for specific routines rather than discarding valuable code. In any case, I just don't want to keep the relevant handling around if it remains untested. Ignoring rounding modes but keeping exceptions is also an option since that should be easier to test.
Anyway, I don't have any strong opinions here so I am opening this issue to see what others think.
The text was updated successfully, but these errors were encountered: