Fixed a bug that pointer subtraction results from two absolute addresses are calculated as unsigned long.
This commit is contained in:
@@ -3353,7 +3353,7 @@ static void parsesub (ExprDesc* Expr)
|
|||||||
Error ("Incompatible pointer types");
|
Error ("Incompatible pointer types");
|
||||||
} else {
|
} else {
|
||||||
Expr->IVal = (Expr->IVal - Expr2.IVal) /
|
Expr->IVal = (Expr->IVal - Expr2.IVal) /
|
||||||
CheckedPSizeOf (lhst);
|
(long)CheckedPSizeOf (lhst);
|
||||||
}
|
}
|
||||||
/* Operate on pointers, result type is an integer */
|
/* Operate on pointers, result type is an integer */
|
||||||
Expr->Type = type_int;
|
Expr->Type = type_int;
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ int main (void)
|
|||||||
fprintf (stderr, "Expected ~32767U == 32768U, got: %ld\n", (long)~32767U);
|
fprintf (stderr, "Expected ~32767U == 32768U, got: %ld\n", (long)~32767U);
|
||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((long*)0x1000 - (long*)0x2000 >= 0) {
|
||||||
|
fprintf (stderr, "Expected (long*)0x1000 - (long*)0x2000 < 0, got: %ld\n", (long*)0x1000 - (long*)0x2000);
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
printf ("failures: %u\n", failures);
|
printf ("failures: %u\n", failures);
|
||||||
|
|
||||||
return failures;
|
return failures;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user