Navigation Menu

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
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

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
Copy link

Change https://golang.org/cl/142719 mentions this issue: cmd/compile: disallow converting string to notinheap slice

@FiloSottile FiloSottile added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 16, 2018
@FiloSottile FiloSottile added this to the Go1.12 milestone Oct 16, 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.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants