commit 787ffacf2b35fb9a3a77c6c6053d5d96d6a3766f
parent b27864c02e4c06be0bac3a0c673d85bb3a281b71
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 27 Mar 2026 06:55:59 +0100
cc1: Use ptrdiff_t for pointer sub
The type in the difference of pointers was correctly pdifftype,
but after dividing by the size of the types then it became int
that defeated the purpose of having ptrdiff_t.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/scc-cc/cc1/expr.c b/src/cmd/scc-cc/cc1/expr.c
@@ -359,7 +359,7 @@ parithmetic(int op, Node *lp, Node *rp)
if ((rp = convert(rp, lp->type, 0)) == NULL)
goto incorrect;
lp = node(OSUB, pdifftype, lp, rp);
- return node(ODIV, inttype, lp, size);
+ return node(ODIV, pdifftype, lp, size);
}
if (!(rp->type->prop & TINTEGER))
goto incorrect;