shithub: scc

Download patch

ref: 9a2a6b23de790bdb10797a424d3720c9505aabc1
parent: c2dc59a3adb69174b02e394ef7f513fb11577dd3
author: Quentin Rameau <quinq@fifth.space>
date: Fri Jun 3 11:26:20 EDT 2016

[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.

--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -505,7 +505,7 @@
 	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);