1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:44:49 -07:00
go/misc/cgo
Ian Lance Taylor 7904946eeb cmd/cgo: discard trailing zero-sized fields in a non-empty C struct
In order to fix issue #9401 the compiler was changed to add a padding
byte to any non-empty Go struct that ends in a zero-sized field.  That
causes the Go version of such a C struct to have a different size than
the C struct, which can considerable confusion.  Change cgo so that it
discards any such zero-sized fields, so that the Go and C structs are
the same size.

This is a change from previous releases, in that it used to be
possible to refer to a zero-sized trailing field (by taking its
address), and with this change it no longer is.  That is unfortunate,
but something has to change.  It seems better to visibly break
programs that do this rather than to silently break programs that rely
on the struct sizes being the same.

Update #9401.
Fixes #11925.

Change-Id: I3fba3f02f11265b3c41d68616f79dedb05b81225
Reviewed-on: https://go-review.googlesource.com/12864
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-30 15:55:25 +00:00
..
errors build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
gmp Fix several out of date references to 4g/5g/6g/8g/9g. 2015-06-26 03:38:21 +00:00
life
nocgo cmd/ld: really import runtime/cgo for external link 2014-05-20 21:36:50 -07:00
stdio
test cmd/cgo: discard trailing zero-sized fields in a non-empty C struct 2015-07-30 15:55:25 +00:00
testasan
testcarchive cmd/go: install headers for c-archive/c-shared cgo exports 2015-05-07 17:39:56 +00:00
testcshared misc/cgo/testcshared: don't leave garbages after test 2015-06-25 19:54:56 +00:00
testgodefs build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
testshared cmd/compile: define func value symbols at declaration 2015-07-20 00:50:46 +00:00
testsigfwd runtime: signal forwarding 2015-04-24 05:19:39 +00:00
testso cmd/dist: convert testso test into Go 2015-06-12 04:33:50 +00:00
testsovar misc/cgo/testsovar: needs the extern keyword to export variables on non-windows platforms 2015-07-21 18:10:57 +00:00
testtls