Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/ssa: fix miscompilation of <<= and >>= statements
Unlike other binary operations, the RHS operand of a shift operation does not need to have the same type as the LHS operand. In particular, for "x <<= y" and "x >>= y" statements, coercing y to have the same type as x can lead to miscompilation. Fixes golang/go#52342. Change-Id: I3ff139afa18f5637d527bd4a0b10d6b40ce53ab4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/400394 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tim King <taking@google.com>
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
func main() { | ||
var d byte | ||
|
||
d = 1 | ||
d <<= 256 | ||
if d != 0 { | ||
panic(d) | ||
} | ||
|
||
d = 1 | ||
d >>= 256 | ||
if d != 0 { | ||
panic(d) | ||
} | ||
} |