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

Closed
mdempsky opened this issue Oct 16, 2018 · 1 comment
Closed

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

mdempsky opened this issue Oct 16, 2018 · 1 comment

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Oct 16, 2018

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 16, 2018

Change https://golang.org/cl/142719 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
@golang golang locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.