Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: heap allocation of go:notinheap type via string conversion #28243

mdempsky opened this issue Oct 16, 2018 · 1 comment


None yet
3 participants
Copy link

commented Oct 16, 2018

cmd/compile accepts this program, even though it involves a heap allocation of a go:notinheap type:

package p

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


This comment has been minimized.

Copy link

commented Oct 16, 2018

Change mentions this issue: cmd/compile: disallow converting string to notinheap slice

@FiloSottile FiloSottile added this to the Go1.12 milestone Oct 16, 2018

@gopherbot gopherbot closed this in b2c397e Nov 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.