From 2145057cb8a50aba1a27a67be19953bee9b164fd Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 25 Feb 2018 14:44:29 +0100 Subject: pkg/compiler: fix alignment corner case Fix alignemnt calculation for packed structs with alignment and bitfields. Amusingly this affected only a single real struct -- ipv6_fragment_ext_header. --- pkg/compiler/gen.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkg/compiler') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index 7f0701ed7..ddcec2252 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -252,7 +252,9 @@ func (comp *compiler) addAlignment(fields []prog.Type, varlen, packed bool, alig if !varlen && alignAttr != 0 { size := uint64(0) for _, f := range fields { - size += f.Size() + if !f.BitfieldMiddle() { + size += f.Size() + } } if tail := size % alignAttr; tail != 0 { newFields = append(newFields, genPad(alignAttr-tail)) -- cgit mrf-deployment