-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: possibly incorrect fused-multiply-add bypassing floating-point to integer conversions #54533
Comments
My guess is that |
In other words, |
I see. Thank you for explaining. I think I was expecting the assignment Is there a way to rewrite my code so that the intermediate result of rounding ( |
Yes, you can force rounding with a Closing, as not a bug. |
Thank you. I confess I cannot find the explanation for how |
Thank you @randall77 ❤️ |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This is the latest 1.18.x release (can't use 1.19.0, waiting for 1.19.1 to release b/c #54302).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Ran the following:
What did you expect to see?
This should not panic.
What did you see instead?
I expect this not to panic because https://go.dev/ref/spec#Conversions states that floating-point to integer conversion rounds toward zero. Thus, the expression should not be negative. It looks like a fused-multiply-add is happening here, when the rules for conversion would not allow it.
The text was updated successfully, but these errors were encountered: