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: incorrect evaluation of conditional in if statement #12266
Comments
Here's the assembly code for g1 and g2:
As an aside, it appears that the function calls g1 and g2 are inlined (as one would hope for) but there's no constant folding after inlining (otherwise the bug would disappear). Presumably this will change with the upcoming SSA-based backend. |
This is most likely the same as #12226 . |
Does it get it wrong on all arches, or just Intel? On Sat, 22 Aug 2015 11:11 Ian Lance Taylor notifications@github.com wrote:
|
Didn't think it could be #12226 because of its title. Actually reading the comments on the issue, it does look like it's the same one. |
Slight difference though - that issue appears to not be present in 1.4.2, while ours does happen in play.golang.org which @griesemer says is running that version. |
Thanks playground was updated to 1.5 overnight, perhaps there was a On Sat, 22 Aug 2015 11:18 Daniel Martí notifications@github.com wrote:
|
Oh, in that case I agree that it's most probably a duplicate. |
With https://golang.org/cl/13771 (fix for #12226) for 1.5 the output is correct:
Looking on the assembler the issue is again go 1.4.2 produces the correct output and doesn't have the issue. The issue is a duplicate of #12226. The playground should display the version as requested in #12218. |
Dave Cheney asked about architectures affected. The bug is in the architecture-independent code generation part of cmd/compile. So multiple architectures may be affected, I could verify the bug and the fix for 386 and AMD64. |
Based on the assembler output of |
Dup of #12226, fixed by CL 13771. |
https://play.golang.org/p/rEXm1QaLgo prints
instead of
This happens both in the playground (currently 1.4) and at tip (1.5) (go version devel +4ec018e Fri Aug 21 13:08:00 2015 -0700 darwin/amd64).
I suspect the condition code register gets clobbered or perhaps is not properly saved/restored across function calls.
Thanks to Daniel Martí (@mvdan) for reporting this.
The text was updated successfully, but these errors were encountered: