Skip to content

cmd/cgo: cgo pointer checking issue with struct fields #25941

Closed
@egonelbre

Description

@egonelbre

Issue: go 1.10.2 and current go tip (b7d9e6e).
Machine: darwin/amd64

When you use a pointer inside to another struct with pointers when calling C then CGO check fails with "panic: runtime error: cgo argument has Go pointer to Go pointer".

Possibly related to #14210

Code to reproduce:

package main

// void exampleCall(void *p) {}
import "C"
import "unsafe"

type Data struct {
	Map          map[int32]int32
	InternalData InternalData
}
type InternalData struct{ X, Y, Z float32 }

func main() {
	data := &Data{}
	data.Map = make(map[int32]int32)
	C.exampleCall(unsafe.Pointer(&data.InternalData))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions