cmd/compile accepts this program, even though it involves a heap allocation of a go:notinheap type:
package p
//go:notinheap
type gcBits uint8
var x []gcBits
func f() {
x = []gcBits("foo") // ([]gcBits)("foo") escapes to heap
}
Unlikely that this would ever be written within package runtime, but seems worth preventing. I think it's just a matter of disallowing string -> []T conversions where T is go:notinheap, like how *T to *U conversions are already special-cased for go:notinheap in convertop.
/cc @aclements
cmd/compile accepts this program, even though it involves a heap allocation of a go:notinheap type:
Unlikely that this would ever be written within package runtime, but seems worth preventing. I think it's just a matter of disallowing string -> []T conversions where T is go:notinheap, like how *T to *U conversions are already special-cased for go:notinheap in convertop.
/cc @aclements