Skip to content
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

nearbyhint: Fix for ffast-math #549

Closed
wants to merge 1 commit into from

Conversation

RafaGago
Copy link

See commit text.

This fixes:
#548

Notice that I wasn't able to verify it on Visual Studio, just g++ and clang.

The fix on 45cad81 wasn't working on
Clang.

On ffast-math the compiler is free to assume that "x + v -v = x".
45cad81 was workarounding this fact by storing "x + v" on a volatile
variable.

For Clang this wasn't enough to stop optimizing, as it correctly
detected that the variable is local-scope, so no one can take a
reference to it.

This commit reworks the fix by defining a function to do the operation
and disabling optimizations on that function for all supported
compilers (and those using the same frontend).

For non-supported compilers an #error is emitted, as the workaround
wasn't safe enough. It could even break between compiler versions. This
avoids potentially weird behaviour on the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant