What version of Go are you using (go version)?
$ go version
go version go1.16.6 linux/amd64
go version go1.17rc1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
Moved from #20021 (comment)
package main
import t "testing"
const N = 1000 * 1000 * 1 // 513
var a [N]byte
var k int
func g(vs ...interface{}) {
type _ int // avoid g being inlined
_ = vs[k]
}
func main() {
{
x := t.AllocsPerRun(1, func() {
g(a)
})
println(int(x))
}
{
x := t.AllocsPerRun(1, func() {
g(a, a)
})
println(int(x))
}
{
x := t.AllocsPerRun(1, func() {
g(a, a, a)
})
println(int(x))
}
{
x := t.AllocsPerRun(1, func() {
g(a, a, a, a)
})
println(int(x))
}
{
x := t.AllocsPerRun(1, func() {
g(a, a, a, a, a)
})
println(int(x))
}
}
What did you expect to see?
1 2 3 4 5
What did you see instead?
1 4 3 4 5
If all are removed but the g(a, a, a) case, then it prints 5, which is also weird.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What did you do?
Moved from #20021 (comment)
What did you expect to see?
1 2 3 4 5
What did you see instead?
1 4 3 4 5
If all are removed but the
g(a, a, a)case, then it prints 5, which is also weird.