From 5ad52cc1ed0f1fbc9781cfac8f59d202ff58738c Mon Sep 17 00:00:00 2001 From: Aleksi Hannula Date: Thu, 5 Feb 2026 09:31:11 +0200 Subject: [PATCH] Cast signed pointer offset to ptrdiff_t before performing arithmetic Affects 32-bit platforms. --- tccgen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tccgen.c b/tccgen.c index 0ea6c288..50802edf 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3097,6 +3097,9 @@ op_err: #endif type1 = vtop[-1].type; vpush_type_size(pointed_type(&vtop[-1].type), &align); + if (!(vtop[-1].type.t & VT_UNSIGNED)) { + gen_cast_s(VT_PTRDIFF_T); + } gen_op('*'); #ifdef CONFIG_TCC_BCHECK if (tcc_state->do_bounds_check && !CONST_WANTED) {