Go version
91267f0
Output of go env in your module/workspace:
What did you do?
The following code behaves differently on 91267f and 1.25.5:
package main
import "fmt"
//go:noinline
func bug1(a []int, i int) int {
if i < 0 || i > 20-len(a) {
return 0
}
diff := len(a) - i
if diff < 10 {
return 1
}
return 2
}
//go:noinline
func bug2(s []int, i int) int {
if i < 0 {
return 0
}
if i <= 10-len(s) {
x := len(s) - i
return x / 2
}
return 0
}
func main() {
if got := bug1(make([]int, 5), 15); got != 1 {
println(fmt.Sprintf("bug1: got %d, want 1", got))
}
if got := bug2(make([]int, 3), 7); got != -2 {
println(fmt.Sprintf("bug2: got %d, want -2", got))
}
}
What did you see happen?
On tip we get:
bug1: got 2, want 1
bug2: got 9223372036854775806, want -2
At 1.25.5, the program runs correctly.
What did you expect to see?
Same behavior as on the release version.
Go version
91267f0
Output of
go envin your module/workspace:What did you do?
The following code behaves differently on 91267f and 1.25.5:
What did you see happen?
On tip we get:
At 1.25.5, the program runs correctly.
What did you expect to see?
Same behavior as on the release version.