scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 96c513c259241630f8397815acfc4da6fcb57237
parent 30feebeac1f5fe74efaf305468fdc332e1b9ee0e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 23 Feb 2017 10:06:58 +0100

[cc1] Fix pointer substraction with void*

At this moment the code was strictly checking if the two
pointers involved in a substraction had the same type,
but this was an error because substracting any pointer
with a null pointer should be allowed.

Diffstat:
Mcc1/expr.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -304,7 +304,7 @@ parithmetic(int op, Node *lp, Node *rp) size = sizeofnode(tp->type); if (op == OSUB && BTYPE(rp) == PTR) { - if (!eqtype(tp, rp->type, 0)) + if ((rp = convert(rp, lp->type, 0)) == NULL) goto incorrect; lp = node(OSUB, pdifftype, lp, rp); return node(ODIV, inttype, lp, size);