ref: 89db1825e0012c166dc6443493c3ebeac21d49e6
parent: caa62432d65dbf35039908832765b7098f48a224
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 26 07:28:09 EDT 2015
Fix types of integer operands in pointer additions The code was adding things of different type, and it was doing casts that were not necessary. This new version does the multiplication in size_t type, and convert the result to pointer.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -457,9 +457,11 @@
}
if (BTYPE(rp) != INT)
goto incorrect;
- rp = node(OCAST, tp, promote(rp), NULL);
- rp = node(OMUL, tp, rp, size);
- return node(op, tp, lp, rp);
+ rp = convert(promote(rp), sizettype, 0);
+ rp = node(OMUL, sizettype, rp, size);
+ rp = node(OCAST, tp, rp, NULL);
+
+ return node(OADD, tp, lp, rp);
incorrect:
error("incorrect arithmetic operands");