Join GitHub today
cmd/cgo: value inconsistency on s390x when passing an int reference to a C function #24212
What version of Go are you using (
It's just that the size of a Go int is different from a C int. Conversions involving unsafe.Pointer are called that way for a reason. The differing results are likely due to endianess (s390x is BE), but it's just as wrong on x86.
Set some of the high bits in the value variable before making the cgo call and you'll see they don't get cleared by the C assignment on x86.
Output on AMD64: