1
2
3
4
5 package cgotest
6
7
12 import "C"
13
14 import (
15 "testing"
16 "unsafe"
17 )
18
19 func test42018(t *testing.T) {
20
21
22
23 var i int
24 handle := C.HANDLE(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
25 recurseHANDLE(100, handle, uintptr(unsafe.Pointer(&i)))
26 hwnd := C.HWND(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
27 recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i)))
28 }
29
30 func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
31 if n > 0 {
32 recurseHANDLE(n-1, p, v)
33 }
34 if uintptr(unsafe.Pointer(p)) != v {
35 panic("adjusted notinheap pointer")
36 }
37 }
38
39 func recurseHWND(n int, p C.HWND, v uintptr) {
40 if n > 0 {
41 recurseHWND(n-1, p, v)
42 }
43 if uintptr(unsafe.Pointer(p)) != v {
44 panic("adjusted notinheap pointer")
45 }
46 }
47
View as plain text