-
-
Notifications
You must be signed in to change notification settings - Fork 407
Closed
Labels
Description
Some operations mark all fields in a struct as used, because we can't do any better. One example is converting to unsafe.Pointer – who knows what the user will do with the data afterwards.
Unfortunately, we're only marking the immediate fields as used:
type t struct {
a, b int
c t2
}
type t2 struct {
d, e int
}
func Foo() {
var x t
_ = unsafe.Pointer(&x)
}
$ run-dev-staticcheck baz.go
baz.go:11:2: field d is unused (U1000)
baz.go:11:5: field e is unused (U1000)
Fields d and e should also be marked as used, as they are part of t's memory layout. The same problem occurs for embedded fields.
Reactions are currently unavailable