1
0
mirror of https://github.com/golang/go synced 2024-11-18 05:24:47 -07:00
go/misc
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
..
android misc/android: cleaner to remove stale GOROOT files 2015-05-25 20:52:10 +00:00
arm
cgo cmd/cgo: discard trailing zero-sized fields in a non-empty C struct 2015-07-30 15:55:25 +00:00
chrome/gophertool all: link to https instead of http 2015-07-11 14:36:33 +00:00
git
ios misc/ios: document the external binary and the required env variables 2015-06-09 22:09:52 +00:00
linkcheck
nacl all: link to https instead of http 2015-07-11 14:36:33 +00:00
swig misc/swig/callback: fix test for SWIG -cgo support 2015-03-06 15:28:50 +00:00
trace cmd/trace: fix time scale 2015-07-01 10:37:10 +00:00
benchcmp all: use golang.org/x/... import paths 2014-11-10 09:15:57 +11:00
editors all: don't refer to code.google.com/p/go{,-wiki}/ 2015-02-06 14:41:47 +00:00