| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | // +build amd64 | 
					
						
							| 
									
										
										
										
											2018-04-02 01:57:49 +02:00
										 |  |  | // errorcheck -0 -d=ssa/prove/debug=1 | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-02 11:07:55 -07:00
										 |  |  | import "math" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | func f0a(a []int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += a[i] // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f0b(a []int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		b := a[i:] // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		x += b[0] | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f0c(a []int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		b := a[:i+1] // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		x += b[0] | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f1(a []int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for _, i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		x += i | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f2(a []int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 1; i < len(a); i++ { // ERROR "Induction variable: limits \[1,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += a[i] // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f4(a [10]int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i += 2 { // ERROR "Induction variable: limits \[0,10\), increment 2$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += a[i] // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f5(a [10]int) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := -10; i < len(a); i += 2 { // ERROR "Induction variable: limits \[-10,10\), increment 2$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		x += a[i] | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func f6(a []int) { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2019-03-08 15:01:32 -08:00
										 |  |  | 		b := a[0:i] // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		f6(b) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g0a(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g0b(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; len(a) > i; i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | func g0c(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := len(a); i > 0; i-- { // ERROR "Induction variable: limits \(0,\?\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i-1]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g0d(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := len(a); 0 < i; i-- { // ERROR "Induction variable: limits \(0,\?\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i-1]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-15 16:52:49 +02:00
										 |  |  | func g0e(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := len(a) - 1; i >= 0; i-- { // ERROR "Induction variable: limits \[0,\?\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:52:49 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g0f(a string) int { | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := len(a) - 1; 0 <= i; i-- { // ERROR "Induction variable: limits \[0,\?\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:52:49 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | func g1() int { | 
					
						
							|  |  |  | 	a := "evenlength" | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i += 2 { // ERROR "Induction variable: limits \[0,10\), increment 2$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		x += int(a[i]) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g2() int { | 
					
						
							|  |  |  | 	a := "evenlength" | 
					
						
							|  |  |  | 	x := 0 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i += 2 { // ERROR "Induction variable: limits \[0,10\), increment 2$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		j := i | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		if a[i] == 'e' { // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 			j = j + 1 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		x += int(a[j]) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return x | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g3a() { | 
					
						
							|  |  |  | 	a := "this string has length 25" | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i += 5 { // ERROR "Induction variable: limits \[0,25\), increment 5$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		useString(a[:i+3]) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g3b(a string) { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i+1:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func g3c(a string) { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 0; i < len(a); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[:i+1]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func h1(a []byte) { | 
					
						
							|  |  |  | 	c := a[:128] | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range c { // ERROR "Induction variable: limits \[0,128\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		c[i] = byte(i) // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func h2(a []byte) { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := range a[:128] { // ERROR "Induction variable: limits \[0,128\), increment 1$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		a[i] = byte(i) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | func k0(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 		a[i-11] = i | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		a[i-10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							|  |  |  | 		a[i-5] = i  // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							|  |  |  | 		a[i] = i    // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							|  |  |  | 		a[i+5] = i  // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							|  |  |  | 		a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 		a[i+11] = i | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func k1(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$" | 
					
						
							| 
									
										
										
										
											2019-03-08 15:01:32 -08:00
										 |  |  | 		useSlice(a[:i-11]) | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useSlice(a[:i-10]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[:i-5])  // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2019-03-08 15:01:32 -08:00
										 |  |  | 		useSlice(a[:i])    // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useSlice(a[:i+5])  // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[:i+10]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[:i+11]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-02 01:57:49 +02:00
										 |  |  | 		useSlice(a[:i+12]) | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func k2(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 		useSlice(a[i-11:]) | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useSlice(a[i-10:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[i-5:])  // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[i:])    // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[i+5:])  // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[i+10:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							|  |  |  | 		useSlice(a[i+11:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-02 01:57:49 +02:00
										 |  |  | 		useSlice(a[i+12:]) | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func k3(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := -10; i < 90; i++ { // ERROR "Induction variable: limits \[-10,90\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-04-02 01:57:49 +02:00
										 |  |  | 		a[i+9] = i | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-02 01:57:49 +02:00
										 |  |  | 		a[i+11] = i | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | func k3neg(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := 89; i > -11; i-- { // ERROR "Induction variable: limits \(-11,89\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 		a[i+9] = i | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 		a[i+11] = i | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func k3neg2(a [100]int) [100]int { | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | 	for i := 89; i >= -10; i-- { // ERROR "Induction variable: limits \[-10,89\], increment 1$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 		a[i+9] = i | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:03:30 +02:00
										 |  |  | 		a[i+11] = i | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | func k4(a [100]int) [100]int { | 
					
						
							|  |  |  | 	min := (-1) << 63 | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := min; i < min+50; i++ { // ERROR "Induction variable: limits \[-9223372036854775808,-9223372036854775758\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		a[i-min] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func k5(a [100]int) [100]int { | 
					
						
							|  |  |  | 	max := (1 << 63) - 1 | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 	for i := max - 50; i < max; i++ { // ERROR "Induction variable: limits \[9223372036854775757,9223372036854775807\), increment 1$" | 
					
						
							|  |  |  | 		a[i-max+50] = i   // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							|  |  |  | 		a[i-(max-70)] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 10:25:48 +02:00
										 |  |  | func d1(a [100]int) [100]int { | 
					
						
							|  |  |  | 	for i := 0; i < 100; i++ { // ERROR "Induction variable: limits \[0,100\), increment 1$" | 
					
						
							|  |  |  | 		for j := 0; j < i; j++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							|  |  |  | 			a[j] = 0   // ERROR "Proved IsInBounds$" | 
					
						
							|  |  |  | 			a[j+1] = 0 // FIXME: this boundcheck should be eliminated | 
					
						
							|  |  |  | 			a[j+2] = 0 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func d2(a [100]int) [100]int { | 
					
						
							|  |  |  | 	for i := 0; i < 100; i++ { // ERROR "Induction variable: limits \[0,100\), increment 1$" | 
					
						
							|  |  |  | 		for j := 0; i > j; j++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							|  |  |  | 			a[j] = 0   // ERROR "Proved IsInBounds$" | 
					
						
							|  |  |  | 			a[j+1] = 0 // FIXME: this boundcheck should be eliminated | 
					
						
							|  |  |  | 			a[j+2] = 0 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func d3(a [100]int) [100]int { | 
					
						
							|  |  |  | 	for i := 0; i <= 99; i++ { // ERROR "Induction variable: limits \[0,99\], increment 1$" | 
					
						
							| 
									
										
										
										
											2022-07-02 11:07:55 -07:00
										 |  |  | 		for j := 0; j <= i-1; j++ { | 
					
						
							|  |  |  | 			a[j] = 0 | 
					
						
							| 
									
										
										
										
											2019-09-16 10:25:48 +02:00
										 |  |  | 			a[j+1] = 0 // ERROR "Proved IsInBounds$" | 
					
						
							|  |  |  | 			a[j+2] = 0 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-02 11:07:55 -07:00
										 |  |  | func d4() { | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 9); i < math.MaxInt64-2; i += 4 { // ERROR "Induction variable: limits \[9223372036854775798,9223372036854775805\), increment 4$" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 8); i < math.MaxInt64-2; i += 4 { // ERROR "Induction variable: limits \[9223372036854775799,9223372036854775805\), increment 4$" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 7); i < math.MaxInt64-2; i += 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 6); i < math.MaxInt64-2; i += 4 { // ERROR "Induction variable: limits \[9223372036854775801,9223372036854775805\), increment 4$" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 9); i <= math.MaxInt64-2; i += 4 { // ERROR "Induction variable: limits \[9223372036854775798,9223372036854775805\], increment 4$" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 8); i <= math.MaxInt64-2; i += 4 { // ERROR "Induction variable: limits \[9223372036854775799,9223372036854775805\], increment 4$" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 7); i <= math.MaxInt64-2; i += 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MaxInt64 - 6); i <= math.MaxInt64-2; i += 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func d5() { | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 9); i > math.MinInt64+2; i -= 4 { // ERROR "Induction variable: limits \(-9223372036854775806,-9223372036854775799\], increment 4" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 8); i > math.MinInt64+2; i -= 4 { // ERROR "Induction variable: limits \(-9223372036854775806,-9223372036854775800\], increment 4" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 7); i > math.MinInt64+2; i -= 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 6); i > math.MinInt64+2; i -= 4 { // ERROR "Induction variable: limits \(-9223372036854775806,-9223372036854775802\], increment 4" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 9); i >= math.MinInt64+2; i -= 4 { // ERROR "Induction variable: limits \[-9223372036854775806,-9223372036854775799\], increment 4" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 8); i >= math.MinInt64+2; i -= 4 { // ERROR "Induction variable: limits \[-9223372036854775806,-9223372036854775800\], increment 4" | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 7); i >= math.MinInt64+2; i -= 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(math.MinInt64 + 6); i >= math.MinInt64+2; i -= 4 { | 
					
						
							|  |  |  | 		useString("foo") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func bce1() { | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	// tests overflow of max-min | 
					
						
							|  |  |  | 	a := int64(9223372036854774057) | 
					
						
							|  |  |  | 	b := int64(-1547) | 
					
						
							|  |  |  | 	z := int64(1337) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if a%z == b%z { | 
					
						
							|  |  |  | 		panic("invalid test: modulos should differ") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-02 11:07:55 -07:00
										 |  |  | 	for i := b; i < a; i += z { // ERROR "Induction variable: limits \[-1547,9223372036854774057\), increment 1337" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		useString("foobar") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func nobce2(a string) { | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := int64(0); i < int64(len(a)); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := int64(0); i < int64(len(a))-31337; i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := int64(0); i < int64(len(a))+int64(-1<<63); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:52:49 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	j := int64(len(a)) - 123 | 
					
						
							|  |  |  | 	for i := int64(0); i < j+123+int64(-1<<63); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							| 
									
										
										
										
											2018-12-04 10:00:16 -05:00
										 |  |  | 		useString(a[i:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" | 
					
						
							| 
									
										
										
										
											2018-04-15 16:52:49 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for i := int64(0); i < j+122+int64(-1<<63); i++ { // ERROR "Induction variable: limits \[0,\?\), increment 1$" | 
					
						
							|  |  |  | 		// len(a)-123+122+MinInt overflows when len(a) == 0, so a bound check is needed here | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | 		useString(a[i:]) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | func nobce3(a [100]int64) [100]int64 { | 
					
						
							|  |  |  | 	min := int64((-1) << 63) | 
					
						
							|  |  |  | 	max := int64((1 << 63) - 1) | 
					
						
							| 
									
										
										
										
											2018-04-02 03:17:18 +02:00
										 |  |  | 	for i := min; i < max; i++ { // ERROR "Induction variable: limits \[-9223372036854775808,9223372036854775807\), increment 1$" | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | 		a[i] = i | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-02 15:21:35 -07:00
										 |  |  | func issue26116a(a []int) { | 
					
						
							|  |  |  | 	// There is no induction variable here. The comparison is in the wrong direction. | 
					
						
							|  |  |  | 	for i := 3; i > 6; i++ { | 
					
						
							|  |  |  | 		a[i] = 0 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for i := 7; i < 3; i-- { | 
					
						
							|  |  |  | 		a[i] = 1 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | //go:noinline | 
					
						
							|  |  |  | func useString(a string) { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-01 15:09:19 +02:00
										 |  |  | //go:noinline | 
					
						
							|  |  |  | func useSlice(a []int) { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 12:58:27 +01:00
										 |  |  | func main() { | 
					
						
							|  |  |  | } |