Closed
Description
Per discussion in golang-dev.
The checkptr
dynamic analyser doesn't find bad type
conversions between types where the destination type is greater than the
source type. E. g.:
var i32sink int32
type t1 struct { a, b int32 }
type t2 struct { a, b, c, d int32 }
func main() {
for i := 0; i < 1000; i++ {
var badt2 = *(*t2)(unsafe.Pointer(&t1{}))
i32sink = badt2.d
}
}
Playground link: https://play.golang.org/p/32lWMkFPvm5.
According to @mdempsky:
Detecting that is not currently supported, but I think there may at least be some cases where we can detect it. (…)