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. --- prog/analysis.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'prog/analysis.go') diff --git a/prog/analysis.go b/prog/analysis.go index c93a13e6c..6a5cd03d9 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -120,9 +120,11 @@ func foreachArgImpl(arg Arg, ctx ArgCtx, f func(Arg, *ArgCtx)) { totalSize += size } } - if totalSize > a.Size() { + claimedSize := a.Size() + varlen := a.Type().Varlen() + if varlen && totalSize > claimedSize || !varlen && totalSize != claimedSize { panic(fmt.Sprintf("bad group arg size %v, should be <= %v for %+v", - totalSize, a.Size(), a)) + totalSize, claimedSize, a)) } case *PointerArg: if a.Res != nil { -- cgit mrf-deployment