Source file
test/fixedbugs/issue51733.go
1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "log"
13 "runtime/cgo"
14 "unsafe"
15 )
16
17 type S struct{ _ cgo.Incomplete }
18
19 func main() {
20 p := (*S)(unsafe.Pointer(uintptr(0x8000)))
21 var v any = p
22 p2 := v.(*S)
23 if p != p2 {
24 log.Fatalf("%p != %p", unsafe.Pointer(p), unsafe.Pointer(p2))
25 }
26 p2 = typeAssert[*S](v)
27 if p != p2 {
28 log.Fatalf("%p != %p from typeAssert", unsafe.Pointer(p), unsafe.Pointer(p2))
29 }
30 }
31
32 func typeAssert[T any](v any) T {
33 return v.(T)
34 }
35
View as plain text