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
I have some...extremely unsafe code that looks like this:
// A closure is the internal representation of a Go func.
// (Actually a Go func is a pointer to one of these.)
type closure struct {
_ structs.HostLayout
code unsafe.Pointer
//lint:ignore U1000 Included to mirror representation of Go func.
ctx unsafe.Pointer
}
The reason I need the //lint:ignore is because I don't do a conversion using unsafe.Pointer(*closure), it is unsafe.Pointer(**closure), so I assume it's bypassing the logic you added for #355.
Anyway, I just added the structs.HostLayout hint (new in Go 1.23) as a way to formally document that I care about the memory layout of this struct. That seems like it could be a good hint to staticcheck that all the fields are needed, so it should skip the U1000 checks. (In fact, this seems like a nicer -- more explicit and more straightforward -- way of detecting "struct fields needed for unsafe reasons" going forward than staticcheck's current heuristics.)
The text was updated successfully, but these errors were encountered:
This is related to #355.
I have some...extremely unsafe code that looks like this:
The reason I need the
//lint:ignore
is because I don't do a conversion usingunsafe.Pointer(*closure)
, it isunsafe.Pointer(**closure)
, so I assume it's bypassing the logic you added for #355.Anyway, I just added the
structs.HostLayout
hint (new in Go 1.23) as a way to formally document that I care about the memory layout of this struct. That seems like it could be a good hint to staticcheck that all the fields are needed, so it should skip the U1000 checks. (In fact, this seems like a nicer -- more explicit and more straightforward -- way of detecting "struct fields needed for unsafe reasons" going forward than staticcheck's current heuristics.)The text was updated successfully, but these errors were encountered: