Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cgo: value inconsistency on s390x when passing an int reference to a C function #24212
What version of Go are you using (
changed the title
Value inconsistency on s390x when passing an int reference to a C function
Mar 2, 2018
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: