[hackers] [scc] [cc2] fix calculation of array sizes || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 3 Jun 2016 18:12:46 +0200 (CEST)

commit 83046300025c0f7afc5a0635480a523410030fa0
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Jun 3 15:26:20 2016 +0200
Commit: Quentin Rameau <quinq_AT_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
_AT_@ -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);
Received on Fri Jun 03 2016 - 18:12:46 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 03 2016 - 18:24:14 CEST