Skip to content

Commit 5ad52cc

Browse files
committed
Cast signed pointer offset to ptrdiff_t before performing arithmetic
Affects 32-bit platforms.
1 parent c937095 commit 5ad52cc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tccgen.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,9 @@ ST_FUNC void gen_op(int op)
30973097
#endif
30983098
type1 = vtop[-1].type;
30993099
vpush_type_size(pointed_type(&vtop[-1].type), &align);
3100+
if (!(vtop[-1].type.t & VT_UNSIGNED)) {
3101+
gen_cast_s(VT_PTRDIFF_T);
3102+
}
31003103
gen_op('*');
31013104
#ifdef CONFIG_TCC_BCHECK
31023105
if (tcc_state->do_bounds_check && !CONST_WANTED) {

0 commit comments

Comments
 (0)