• Ian Lance Taylor's avatar
    cmd/cgo: use field alignment when setting field offset · fbdaa965
    Ian Lance Taylor authored
    The old code ignored the field alignment, and only looked at the field
    offset: if the field offset required padding, cgo added padding. But
    while that approach works for Go (at least with the gc toolchain) it
    doesn't work for C code using packed structs. With a packed struct the
    added padding may leave the struct at a misaligned position, and the
    inserted alignment, which cgo is not considering, may introduce
    additional, unexpected, padding. Padding that ignores alignment is not
    a good idea when the struct is not packed, and Go structs are never
    packed. So don't ignore alignment.
    
    Fixes #28896
    
    Change-Id: Ie50ea15fa6dc35557497097be9fecfecb11efd8a
    Reviewed-on: https://go-review.googlesource.com/c/150602
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
    fbdaa965
Name
Last commit
Last update
..
android Loading commit data...
arm Loading commit data...
cgo Loading commit data...
chrome/gophertool Loading commit data...
git Loading commit data...
ios Loading commit data...
linkcheck Loading commit data...
nacl Loading commit data...
sortac Loading commit data...
swig Loading commit data...
trace Loading commit data...
wasm Loading commit data...
benchcmp Loading commit data...
editors Loading commit data...