mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-24 10:00:07 +08:00
Pointer diff should use signed size
This commit is contained in:
parent
76d605192d
commit
a0ab99169e
1
tccgen.c
1
tccgen.c
@ -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;
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user