[hackers] [scc] Fix calculation of sizes in structs || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 25 Aug 2015 23:42:42 +0200 (CEST)

commit caa62432d65dbf35039908832765b7098f48a224
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Aug 25 23:39:41 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Aug 25 23:39:41 2015 +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.

diff --git a/cc1/types.c b/cc1/types.c
index c79a8f9..2bf3a84 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -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:
Received on Tue Aug 25 2015 - 23:42:42 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 25 2015 - 23:48:11 CEST