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: failure to reject embedding of unsafe.Pointer in struct #14729

Closed
mdempsky opened this issue Mar 9, 2016 · 1 comment
Closed
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Mar 9, 2016

cmd/compile accepts this invalid Go source file:

package p
import "unsafe"
type s struct { unsafe.Pointer }

gotype and gccgo correctly reject it:

$ gotype p.go
p.go:3:17: anonymous field type cannot be unsafe.Pointer
$ gccgo-4.8 -c p.go
p.go:3:17: error: embedded type may not be a pointer
 type s struct { unsafe.Pointer }
                 ^

The Go spec says:

A field declared with a type but no explicit field name is an anonymous field, also called an embedded field or an embedding of the type in the struct. An embedded type must be specified as a type name T or as a pointer to a non-interface type name *T, and T itself may not be a pointer type.

And later describing package unsafe:

A Pointer is a pointer type but a Pointer value may not be dereferenced.

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Mar 10, 2016
@gopherbot
Copy link

CL https://golang.org/cl/22325 mentions this issue.

@golang golang locked and limited conversation to collaborators Apr 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants