1
0
mirror of https://github.com/golang/go synced 2024-09-29 22:34:33 -06:00
go/misc/cgo
Ian Lance Taylor fbdaa96563 cmd/cgo: use field alignment when setting field offset
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: Bryan C. Mills <bcmills@google.com>
2018-11-29 19:18:12 +00:00
..
errors cmd/cgo: rewrite pointer checking to use more function literals 2018-11-01 21:54:54 +00:00
fortran *.bash: always use the same string equality operator 2017-03-14 21:46:31 +00:00
gmp
life test: remove rundircmpout and cmpout actions 2018-05-31 17:36:45 +00:00
nocgo
stdio test: remove rundircmpout and cmpout actions 2018-05-31 17:36:45 +00:00
test cmd/cgo: use field alignment when setting field offset 2018-11-29 19:18:12 +00:00
testasan
testcarchive misc/cgo/testcarchive: make the tests work when using gccgo 2018-08-21 15:03:10 +00:00
testcshared misc/cgo/testcshared: force descriptor 30 to be closed when execing test 2018-08-01 23:10:11 +00:00
testgodefs cmd/cgo: don't resolve typedefs in -godefs mode 2018-07-27 16:46:42 +00:00
testplugin all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
testsanitizers misc/cgo/testsanitizers: gofmt 2018-11-16 13:54:47 +00:00
testshared all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
testsigfwd
testso
testsovar
testtls