1
0
Fork 0

Pointer diff should use signed size

This commit is contained in:
herman ten brugge 2024-02-09 08:35:32 +01:00
parent 76d605192d
commit a0ab99169e
2 changed files with 5 additions and 1 deletions

View File

@ -2983,6 +2983,7 @@ redo:
if (op != '-')
tcc_error("cannot use pointers here");
vpush_type_size(pointed_type(&vtop[-1].type), &align);
vtop->type.t &= ~VT_UNSIGNED;
vrott(3);
gen_opic(op);
vtop->type.t = VT_PTRDIFF_T;

View File

@ -885,7 +885,7 @@ int tab4[10];
void expr_ptr_test()
{
int *p, *q;
int arr[10], *p, *q;
int i = -1;
p = tab4;
@ -938,6 +938,9 @@ void expr_ptr_test()
i = ((long)p) >> 32;
printf("largeptr: %p %d\n", p, i);
#endif
p = &arr[0];
q = p + 3;
printf ("%d\n", (int)((p - q) / 3));
}
void expr_cmp_test()