Skip to content

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

Closed

Description

@mdempsky

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

Activity

  1. gopherbot commented on Oct 16, 2018

    @gopherbot
    Contributor

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

  2. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Oct 16, 2018
  3. added this to the Go1.12 milestone on Oct 16, 2018
  4. locked and limited conversation to collaborators on Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions