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: invalid conversion from a negative float to uint64 on arm64 #43047
Comments
I can confirm that go1.13 is affected.
|
Change https://golang.org/cl/275832 mentions this issue: |
The Go spec reads
So it is totally okay for |
@cherrymui I agreed with you that it's an undefined behavior in spec. |
Sounds good, thank you for chiming in @mengzhuo and @cherrymui! Marking as won't fix due to undefined behavior. |
On aarch64, the conversion of a negative float to
uint64
yields0
.What version of Go are you using (
go version
)?go version go1.15 linux/arm64
Does this issue reproduce with the latest release?
Yes, and it has been present since at least 1.13
What operating system and processor architecture are you using (
go env
)?What did you do?
The following program reproduces the error:
x86_64 output:
aarch64 output:
What did you expect to see?
Expecting the outputs for x86_64 and aarch64 to be exactly the same might not be reasonable, due to differences in hardware implementations. At the very least, I would expect the output of
uint64(<float>)
anduint64(int64(<float>))
to be the same.What did you see instead?
uint64(-64.0) == 0
anduint64(int64(-64.0)) == 18446744073709551552
The text was updated successfully, but these errors were encountered: