Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: nested structure has too much alignment padding [1.11 backport] #28916

gopherbot opened this issue Nov 21, 2018 · 2 comments


Copy link

commented Nov 21, 2018

@ianlancetaylor requested issue #28896 to be considered for backport to the next 1.11 minor release.

@gopherbot Please open an issue to backport to 1.11.


This comment has been minimized.

Copy link

commented Nov 29, 2018

Change mentions this issue: [release-branch.go1.11] cmd/cgo: use field alignment when setting field offset


This comment has been minimized.

Copy link

commented Dec 3, 2018

Closed by merging 6fa0ace to release-branch.go1.11.

@gopherbot gopherbot closed this Dec 3, 2018

gopherbot pushed a commit that referenced this issue Dec 3, 2018
[release-branch.go1.11] cmd/cgo: use field alignment when setting fie…
…ld 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.

Updates #28896
Fixes #28916

Change-Id: Ie50ea15fa6dc35557497097be9fecfecb11efd8a
Run-TryBot: Ian Lance Taylor <>
Reviewed-by: Bryan C. Mills <>
(cherry picked from commit fbdaa96)
TryBot-Result: Gobot Gobot <>

@dmitshur dmitshur modified the milestones: Go1.11.3, Go1.11.4 Dec 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.