What version of Go are you using (go version)?
$ go version
go version go1.14.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
What did you do?
Compile
package main
func test(foo []byte, i int) {
_ = foo[63]
r := i & 63
_ = foo[r]
}
func main() {}
go build -gcflags="-d=ssa/check_bce/debug=1"
What did you expect to see?
Just the first bounds check for the initial length of the slice
./test.go:4:9: Found IsInBounds
Because prove should be able to deduce that the masked value is bounded by 63 and so is already in bounds.
r := i&m && m >= 0 --> 0 <= r <= m
What did you see instead?
Both accesses require a bounds check.
./test.go:4:9: Found IsInBounds
./test.go:6:9: Found IsInBounds
This is related to #38476
@rasky @josharian @zdjones
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
Compile
go build -gcflags="-d=ssa/check_bce/debug=1"What did you expect to see?
Just the first bounds check for the initial length of the slice
Because prove should be able to deduce that the masked value is bounded by 63 and so is already in bounds.
r := i&m && m >= 0 --> 0 <= r <= mWhat did you see instead?
Both accesses require a bounds check.
This is related to #38476
@rasky @josharian @zdjones