commit 83046300025c0f7afc5a0635480a523410030fa0
Author:     Quentin Rameau <quinq@fifth.space>
AuthorDate: Fri Jun 3 15:26:20 2016 +0200
Commit:     Quentin Rameau <quinq@fifth.space>
CommitDate: Fri Jun 3 18:10:21 2016 +0200

    [cc2] fix calculation of array sizes
    
    cc1 emits the number of elements of arrays, so we need in cc2 to
    multiply that number with the size of the elements type to get the
    actual size.

diff --git a/cc2/parser.c b/cc2/parser.c
index 077d95a..f76f09c 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -505,7 +505,7 @@ array(void)
        size = pop();
        base = pop();
        tp = pop();
-       tp->size = size->u.i;
+       tp->size = size->u.i * base->size; /* FIXME check for overflow */
        tp->align = base->align;
 
        delnode(size);

Reply via email to