Closed
Description
package main
type T int
const K T = 5
type P struct {
a [K]*byte
}
func f(p *P) {
for i := range K {
p.a[i] = nil
}
}
Fails to compile with the kinda cryptic error:
tmp1.go:12:17: cannot use len(p.a) - 1 (type int) as type T in assignment
This gets triggered when rewriting that loop to a runtime.memclrHasPointers
call.
It is trying to compute the final value for i
as len(a)-1
, when it should really be T(len(a)-1)
.
This started happening recently and was noticed inside google. Triggered by CL 659317, not sure exactly why that CL is implicated.