diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-02-25 14:44:29 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-02-25 14:44:29 +0100 |
| commit | 2145057cb8a50aba1a27a67be19953bee9b164fd (patch) | |
| tree | a8a5b759ef44ad1a88f1bf3064283ff3caa7fc69 /prog/analysis.go | |
| parent | 1f4ae3f41357cf0a8cf8c698cbcd1000b8b44bf4 (diff) | |
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.
Diffstat (limited to 'prog/analysis.go')
| -rw-r--r-- | prog/analysis.go | 6 |
1 files changed, 4 insertions, 2 deletions
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 { |
