2 // errorcheck -0 -d=ssa/check_bce/debug=3
7 a[0] = 1 // ERROR "Found IsInBounds$"
9 a[6] = 1 // ERROR "Found IsInBounds$"
15 func f1(a [256]int, i int) {
17 useInt(a[i]) // ERROR "Found IsInBounds$"
19 useInt(a[j]) // ERROR "Found IsInBounds$"
25 if 4 <= i && i < len(a) {
27 useInt(a[i-1]) // ERROR "Found IsInBounds$"
28 // TODO: 'if 4 <= i && i < len(a)' gets rewritten to 'if uint(i - 4) < 256 - 4',
29 // which the bounds checker cannot yet use to infer that the next line doesn't need a bounds check.
34 func f2(a [256]int, i uint) {
35 useInt(a[i]) // ERROR "Found IsInBounds$"
44 func f2a(a [35]int, i uint8) {
45 useInt(a[i]) // ERROR "Found IsInBounds$"
52 func f2b(a [35]int, i uint16) {
53 useInt(a[i]) // ERROR "Found IsInBounds$"
60 func f2c(a [35]int, i uint32) {
61 useInt(a[i]) // ERROR "Found IsInBounds$"
68 func f3(a [256]int, i uint8) {
74 func f4(a [27]int, i uint8) {
88 func f6(a [32]int, b [64]int, i int) {
89 useInt(a[uint32(i*0x07C4ACDD)>>27])
90 useInt(b[uint64(i*0x07C4ACDD)>>58])
91 useInt(a[uint(i*0x07C4ACDD)>>59])
93 // The following bounds should not be removed because they can overflow.
94 useInt(a[uint32(i*0x106297f105d0cc86)>>26]) // ERROR "Found IsInBounds$"
95 useInt(b[uint64(i*0x106297f105d0cc86)>>57]) // ERROR "Found IsInBounds$"
96 useInt(a[int32(i*0x106297f105d0cc86)>>26]) // ERROR "Found IsInBounds$"
97 useInt(b[int64(i*0x106297f105d0cc86)>>57]) // ERROR "Found IsInBounds$"
109 useInt(a[3]) // ERROR "Found IsInBounds$"
116 for i := range a[:256] { // ERROR "Found IsSliceInBounds$"
117 useInt(a[i]) // ERROR "Found IsInBounds$"
125 func g4(a [100]int) {
126 for i := 10; i < 50; i++ {
132 // The following are out of bounds.
133 useInt(a[i-11]) // ERROR "Found IsInBounds$"
134 useInt(a[i+51]) // ERROR "Found IsInBounds$"
143 func useSlice(a []int) {