-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: string range loop does not handle assigment order correctly #18376
Comments
It took me a bit to see what's wrong with the behavior. In case it helps anyone else looking at this, the specific issue is that spec says
(link). Below that it also gives this example for an
|
I agree that this looks like a bug in the gc compiler. gccgo gets it right. I also agree with setting the milestone for this to 1.9. |
Since the fix will be for 1.9 i will take a little more time for tuning the performance of the fix before submitting a CL. |
We should add this test case to $GOROOT/test/range.go, analogous to what
FWIW, golang.org/x/tools/go/ssa also does the right thing. |
@alandonovan sure, that what i did to verify the bug too (and then copied to the playground link) and will be in the CL. However i put the test into teststring function similar to testslice. |
CL https://golang.org/cl/35955 mentions this issue. |
at least go 1.7.4 (playground) and tip
https://play.golang.org/p/CG--RNbwZA
expected:
x[0] = 'a'
x[1] = 'c'
got:
x[0] = 'c'
x[1] = 'b'
I have already created a fix for this issue. Currently testing if we could make it not regress performance for the common case (e.g. i,x := ) without adding to much additional complexity to the compiler code.
Note that this bug seems not to have been introduced with the new string range code but already existed in at least 1.7.4 . However the new string range code in 1.8 does not handle this case correctly either.
The text was updated successfully, but these errors were encountered: