Skip to content

cmd/compile: adjustment needed for conversion rules for pointer conversions (?) #50815

@keep94

Description

@keep94

What version of Go are you using (go version)?

go1.18-16d6a5233a Tue Jan 25 00:39:08 2022 +0000. Using gotipplay.golang.org.

Does this issue reproduce with the latest release?

No.

What operating system and processor architecture are you using (go env)?

I am using gotipplay.golang.org.

What did you do?

func Sum[Slice ~[]int](aslice Slice) int {
    p := (*[]int)(&aslice) // compile error: cannot convert &slice (value of type *Slice) to type *[]int
    result := 0
    for _, y := range *p {
        result += y
    }
    return result
}

What did you expect to see?

I expect p to be a *[]int

What did you see instead?

A compile error. cannot convert &slice (value of type *Slice) to type *[]int.

Metadata

Metadata

Assignees

Labels

NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.genericsIssue is related to generics

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions