1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Overflow test optimization suggested by kugelfuhr

User CHAR_BIT instead of 8
This commit is contained in:
bbbradsmith 2023-05-04 05:44:20 -04:00
parent b5f255f912
commit ca8201a314

View File

@ -590,19 +590,15 @@ static void NumericConst (void)
SB_Clear (&Src);
break;
}
if (((scan_t)(IVal * Base) / Base) != IVal) {
if (((scan_t)(IVal * Base + DigitVal) / Base) != IVal) {
Overflow = 1;
}
IVal = IVal * Base;
if (((scan_t)(IVal + DigitVal)) < IVal) {
Overflow = 1;
}
IVal += DigitVal;
IVal = IVal * Base + DigitVal;
SB_Skip (&Src);
}
if (Overflow) {
Error ("Numerical constant \"%s\" too large for internal %d-bit representation",
SB_GetConstBuf (&Src), (int)(sizeof(IVal)*8));
SB_GetConstBuf (&Src), (int)(sizeof(IVal)*CHAR_BIT));
}
/* Distinguish between integer and floating point constants */