mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/compile: add testcase for #24876
This is still not fixed, the testcase reflects that there are still a few boundchecks. Let's fix the good alternative with an explicit test though. Updates #24876 Change-Id: I4da35eb353e19052bd7b69ea6190a69ced8b9b3d Reviewed-on: https://go-review.googlesource.com/107355 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f02cc88f46
commit
dd5e9b32ff
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "encoding/binary"
|
||||||
|
|
||||||
func f0(a []int) {
|
func f0(a []int) {
|
||||||
a[0] = 1 // ERROR "Found IsInBounds$"
|
a[0] = 1 // ERROR "Found IsInBounds$"
|
||||||
a[0] = 1
|
a[0] = 1
|
||||||
@ -142,6 +144,33 @@ func g4(a [100]int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decode1(data []byte) (x uint64) {
|
||||||
|
for len(data) >= 32 {
|
||||||
|
x += binary.BigEndian.Uint64(data[:8])
|
||||||
|
x += binary.BigEndian.Uint64(data[8:16])
|
||||||
|
x += binary.BigEndian.Uint64(data[16:24])
|
||||||
|
x += binary.BigEndian.Uint64(data[24:32])
|
||||||
|
data = data[32:]
|
||||||
|
}
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
|
func decode2(data []byte) (x uint64) {
|
||||||
|
// TODO(rasky): this should behave like decode1 and compile to no
|
||||||
|
// boundchecks. We're currently not able to remove all of them.
|
||||||
|
for len(data) >= 32 {
|
||||||
|
x += binary.BigEndian.Uint64(data)
|
||||||
|
data = data[8:]
|
||||||
|
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
|
||||||
|
data = data[8:]
|
||||||
|
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
|
||||||
|
data = data[8:]
|
||||||
|
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
|
||||||
|
data = data[8:]
|
||||||
|
}
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
//go:noinline
|
//go:noinline
|
||||||
func useInt(a int) {
|
func useInt(a int) {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user