You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
cmd/compile accepts this invalid Go source file:
gotype and gccgo correctly reject it:
The Go spec says:
And later describing package unsafe:
The text was updated successfully, but these errors were encountered: