Pointer difference operations should have some type that corresponds to ptrdiff_t, but the cabs2cil transformation creates them with type "int". The "int" type is often not as big as ptrdiff_t. The result of this that sometimes the types of the arguments of binary operators do not match (though CIL thinks they do).
Consider the following program:
int main()
{
int i;
int *p = &i;
int *q = &p;
short s = 1;
long d = (p - q) + s;
return 0;
}
CIL will translate the statement "d = (p - q) + s;" to "d = (long)((p - q) + (int)s);". It should have created "d = (long)((p - q) + (ptrdiff_t)s);".
A patch to fix the bug is attached.
Patch to fix bug.
Applied, thanks.