2 // errorcheck -0 -d=ssa/prove/debug=3
4 // Copyright 2016 The Go Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
12 func f0(a []int) int {
14 a[0] = 1 // ERROR "Proved boolean IsInBounds$"
16 a[6] = 1 // ERROR "Proved boolean IsInBounds$"
17 a[5] = 1 // ERROR "Proved IsInBounds$"
18 a[5] = 1 // ERROR "Proved boolean IsInBounds$"
22 func f1(a []int) int {
26 a[0] = 1 // ERROR "Proved non-negative bounds IsInBounds$"
27 a[0] = 1 // ERROR "Proved boolean IsInBounds$"
29 a[6] = 1 // ERROR "Proved boolean IsInBounds$"
30 a[5] = 1 // ERROR "Proved IsInBounds$"
31 a[5] = 1 // ERROR "Proved boolean IsInBounds$"
35 func f1b(a []int, i int, j uint) int {
36 if i >= 0 && i < len(a) {
37 return a[i] // ERROR "Proved non-negative bounds IsInBounds$"
39 if i >= 10 && i < len(a) {
40 return a[i] // ERROR "Proved non-negative bounds IsInBounds$"
42 if i >= 10 && i < len(a) {
43 return a[i] // ERROR "Proved non-negative bounds IsInBounds$"
45 if i >= 10 && i < len(a) { // todo: handle this case
49 return a[j] // ERROR "Proved IsInBounds$"
54 func f1c(a []int, i int64) int {
55 c := uint64(math.MaxInt64 + 10) // overflows int
57 if i >= d && i < int64(len(a)) {
58 // d overflows, should not be handled.
64 func f2(a []int) int {
67 a[i+1] = i // ERROR "Proved boolean IsInBounds$"
72 func f3(a []uint) int {
73 for i := uint(0); i < uint(len(a)); i++ {
74 a[i] = i // ERROR "Proved IsInBounds$"
79 func f4a(a, b, c int) int {
81 if a == b { // ERROR "Disproved Eq64$"
84 if a > b { // ERROR "Disproved Greater64$"
87 if a < b { // ERROR "Proved boolean Less64$"
90 if a == b { // ERROR "Disproved boolean Eq64$"
93 if a > b { // ERROR "Disproved boolean Greater64$"
101 func f4b(a, b, c int) int {
104 if a == b { // ERROR "Proved Eq64$"
114 func f4c(a, b, c int) int {
117 if a != b { // ERROR "Disproved Neq64$"
127 func f4d(a, b, c int) int {
130 if a < b { // ERROR "Proved boolean Less64$"
131 if a < c { // ERROR "Proved boolean Less64$"
143 func f4e(a, b, c int) int {
145 if b > a { // ERROR "Proved Greater64$"
153 func f4f(a, b, c int) int {
156 if b == a { // ERROR "Disproved Eq64$"
161 if b >= a { // ERROR "Proved Geq64$"
162 if b == a { // ERROR "Proved Eq64$"
172 func f5(a, b uint) int {
174 if a <= b { // ERROR "Proved Leq64U$"
182 // These comparisons are compile time constants.
183 func f6a(a uint8) int {
184 if a < a { // ERROR "Disproved Less8U$"
190 func f6b(a uint8) int {
191 if a < a { // ERROR "Disproved Less8U$"
197 func f6x(a uint8) int {
198 if a > a { // ERROR "Disproved Greater8U$"
204 func f6d(a uint8) int {
205 if a <= a { // ERROR "Proved Leq8U$"
211 func f6e(a uint8) int {
212 if a >= a { // ERROR "Proved Geq8U$"
218 func f7(a []int, b int) int {
221 if b < len(a) { // ERROR "Proved boolean Less64$"
222 a[b] = 5 // ERROR "Proved boolean IsInBounds$"
228 func f8(a, b uint) int {
235 if a < b { // ERROR "Proved Less64U$"
241 func f9(a, b bool) int {
245 if a || b { // ERROR "Disproved boolean Arg$"
251 func f10(a string) int {
253 if a[:n>>1] == "aaa" {
259 func f11a(a []int, i int) {
261 useInt(a[i]) // ERROR "Proved boolean IsInBounds$"
264 func f11b(a []int, i int) {
266 useSlice(a[i:]) // ERROR "Proved boolean IsSliceInBounds$"
269 func f11c(a []int, i int) {
271 useSlice(a[:i]) // ERROR "Proved boolean IsSliceInBounds$"
274 func f11d(a []int, i int) {
279 func f12(a []int, b int) {
283 func f13a(a, b, c int, x bool) int {
286 if a < 12 { // ERROR "Disproved Less64$"
291 if a <= 12 { // ERROR "Disproved Leq64$"
296 if a == 12 { // ERROR "Disproved Eq64$"
301 if a >= 12 { // ERROR "Proved Geq64$"
306 if a > 12 { // ERROR "Proved boolean Greater64$"
315 func f13b(a int, x bool) int {
318 if a < -9 { // ERROR "Disproved Less64$"
323 if a <= -9 { // ERROR "Proved Leq64$"
328 if a == -9 { // ERROR "Proved boolean Eq64$"
333 if a >= -9 { // ERROR "Proved Geq64$"
338 if a > -9 { // ERROR "Disproved Greater64$"
347 func f13c(a int, x bool) int {
350 if a < 90 { // ERROR "Proved boolean Less64$"
355 if a <= 90 { // ERROR "Proved Leq64$"
360 if a == 90 { // ERROR "Disproved Eq64$"
365 if a >= 90 { // ERROR "Disproved Geq64$"
370 if a > 90 { // ERROR "Disproved Greater64$"
379 func f13d(a int) int {
381 if a < 9 { // ERROR "Proved Less64$"
388 func f13e(a int) int {
390 if a > 5 { // ERROR "Proved Greater64$"
397 func f13f(a int64) int64 {
398 if a > math.MaxInt64 {
399 // Unreachable, but prove doesn't know that.
407 func f13g(a int) int {
414 if a == 3 { // ERROR "Proved Eq64$"
420 func f13h(a int) int {
423 if a == 2 { // ERROR "Proved Eq64$"
431 func f13i(a uint) int {
435 if a > 0 { // ERROR "Proved Greater64U$"
446 func useSlice(a []int) {