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
gccgo: math: Ldexp mishandles exp larger than 32-bit #21323
Comments
Cherry, I can take a shot at fixing this if you don't already have a CL -- let me know. |
@thanm, thank you. |
Change https://golang.org/cl/54230 mentions this issue: |
Add test cases to verify behavior for Ldexp with exponents outside the range of Minint32/Maxint32, for a gccgo bug. Test for issue #21323. Change-Id: Iea67bc6fcfafdfddf515cf7075bdac59360c277a Reviewed-on: https://go-review.googlesource.com/54230 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Fix by https://go-review.googlesource.com/c/54250 |
It didn't auto-close because it wasn't written as "#21323". Sorry I didn't catch that. |
Ah ok, thanks. I'll try to remember. |
What version of Go are you using (
go version
)?Go tip (~1.9), gccgo
gccgo (GCC) 8.0.0 20170725 (experimental)
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
What did you expect to see?
With gc toolchain, the program above prints
+Inf
on linux/amd64. I believe this is the expected result.What did you see instead?
With gccgo, the program above prints 2 on linux/amd64.
gccgo's math.Ldexp uses libc_ldexp, which is defined in C as
double ldexp(double x, int exp)
. On linux/amd64, C's int is 32-bit whereas Go's int is 64-bit, causing this problem.@ianlancetaylor
The text was updated successfully, but these errors were encountered: