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/gc: Slice access of const causes strange string errors (Bug introduced in go1.3, doesn't happen in go <= 1.2) #8325
Labels
Milestone
Comments
The generated code is wrong for b % 36. The theoretical equivalent expression is: b - 36*(b/36) where b/36 is represented by uint16(b) * 57 >> 11 (2048/57 = 35.9298...) The generated code is: 0x007f 00127 (z.go:7) MOVBQZX (SI),BP => BP = b 0x0083 00131 (z.go:7) MOVQ BP,DI => DI = b too. 0x0086 00134 (z.go:8) CMPQ CX,R9 0x0089 00137 (z.go:8) JCC $1,325 0x008f 00143 (z.go:8) LEAQ (R10)(CX*1),BX 0x0093 00147 (z.go:8) MOVQ $57,R8 0x009a 00154 (z.go:8) MOVQ BP,AX 0x009d 00157 (z.go:8) MULB R8B, => AH:AL = uint16(b)*57 0x00a0 00160 (z.go:8) MOVB AH,DL => b/36 is DL>>3 => we are missing a MOVB DL, BPB here 0x00a2 00162 (z.go:8) SHRB $3,BPB => BP>>3 is not what we want. 0x00a6 00166 (z.go:8) MOVQ $36,R8 0x00ad 00173 (z.go:8) IMULQ R8,BP 0x00b1 00177 (z.go:8) MOVQ DI,R8 0x00b4 00180 (z.go:8) SUBQ BP,R8 => R8 = DI - 36*BP 0x00b7 00183 (z.go:8) MOVBQZX R8B,BP 0x00bb 00187 (z.go:8) LEAQ go.string."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"+16(SB)(BP*1),R8 The wrong code results in wrong index (> 36) taken in the constant string. Status changed to Started. |
CL https://golang.org/cl/104560044 mentions this issue. |
CL https://golang.org/cl/124950043 mentions this issue. |
This issue was closed by revision 5b63ce4. Status changed to Fixed. |
adg
added a commit
that referenced
this issue
May 11, 2015
…tiply ««« CL 124950043 / 8e5ec6948793 cmd/6g, cmd/8g: fix, test byte-sized magic multiply Credit to Rémy for finding and writing test case. Fixes #8325. LGTM=r R=golang-codereviews, r CC=dave, golang-codereviews, iant, remyoudompheng https://golang.org/cl/124950043 »»» TBR=rsc CC=golang-codereviews https://golang.org/cl/126000043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Credit to Rémy for finding and writing test case. Fixes golang#8325. LGTM=r R=golang-codereviews, r CC=dave, golang-codereviews, iant, remyoudompheng https://golang.org/cl/124950043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Credit to Rémy for finding and writing test case. Fixes golang#8325. LGTM=r R=golang-codereviews, r CC=dave, golang-codereviews, iant, remyoudompheng https://golang.org/cl/124950043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by psnim2000:
The text was updated successfully, but these errors were encountered: