Skip to content

Commit 8c1c670

Browse files
ALTreebradfitz
authored andcommitted
test: restore binary.BigEndian use in checkbce
CL 136855 removed the encoding/binary dependency from the checkbce.go test by defining a local Uint64 to fix the noopt builder; then a more general mechanism to skip tests on the noopt builder was introduced in CL 136898, so we can now restore the binary.Uint64 calls in testbce. Change-Id: I3efbb41be0bfc446a7e638ce6a593371ead2684f Reviewed-on: https://go-review.googlesource.com/137056 Run-TryBot: Alberto Donizetti <[email protected]> Reviewed-by: Giovanni Bajo <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 5be7866 commit 8c1c670

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

test/checkbce.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
package main
1212

13+
import "encoding/binary"
14+
1315
func f0(a []int) {
1416
a[0] = 1 // ERROR "Found IsInBounds$"
1517
a[0] = 1
@@ -142,18 +144,12 @@ func g4(a [100]int) {
142144
}
143145
}
144146

145-
func Uint64(b []byte) uint64 {
146-
_ = b[7] // ERROR "Found IsInBounds$"
147-
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
148-
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
149-
}
150-
151147
func decode1(data []byte) (x uint64) {
152148
for len(data) >= 32 {
153-
x += Uint64(data[:8])
154-
x += Uint64(data[8:16])
155-
x += Uint64(data[16:24])
156-
x += Uint64(data[24:32])
149+
x += binary.BigEndian.Uint64(data[:8])
150+
x += binary.BigEndian.Uint64(data[8:16])
151+
x += binary.BigEndian.Uint64(data[16:24])
152+
x += binary.BigEndian.Uint64(data[24:32])
157153
data = data[32:]
158154
}
159155
return x
@@ -163,13 +159,13 @@ func decode2(data []byte) (x uint64) {
163159
// TODO(rasky): this should behave like decode1 and compile to no
164160
// boundchecks. We're currently not able to remove all of them.
165161
for len(data) >= 32 {
166-
x += Uint64(data)
162+
x += binary.BigEndian.Uint64(data)
167163
data = data[8:]
168-
x += Uint64(data) // ERROR "Found IsInBounds$"
164+
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
169165
data = data[8:]
170-
x += Uint64(data) // ERROR "Found IsInBounds$"
166+
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
171167
data = data[8:]
172-
x += Uint64(data) // ERROR "Found IsInBounds$"
168+
x += binary.BigEndian.Uint64(data) // ERROR "Found IsInBounds$"
173169
data = data[8:]
174170
}
175171
return x

0 commit comments

Comments
 (0)