scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit caa62432d65dbf35039908832765b7098f48a224
parent 5333c3cfde5f199f893cf52c4476f173b672bba0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 25 Aug 2015 23:39:41 +0200

Fix calculation of sizes in structs

The aligment calculus was wrong because we were taking
the values from a wrong type pointer and because the
phormula failed when size&align == 0.

Diffstat:
Mcc1/types.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -279,11 +279,9 @@ typesize(Type *tp) n = tp->n.elem; for (sp = tp->p.fields; n--; ++sp) { tp = (*sp)->type; + align = tp->align-1; + size = size + align & ~align; size += tp->size; - if (n > 0) { - align = tp->align - 1; - size += align - (size & align); - } } return size; case UNION: