ubsan: expr.c:1725,1741 signed integer overflow

* expr.c (add_to_result, subtract_from_result): Use unsigned
	addition and subtraction.
This commit is contained in:
Alan Modra
2020-09-02 10:29:21 +09:30
parent 01a6f9da64
commit c77a6ef610
2 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2020-09-02 Alan Modra <amodra@gmail.com>
* expr.c (add_to_result, subtract_from_result): Use unsigned
addition and subtraction.
2020-09-02 Alan Modra <amodra@gmail.com>
* config/tc-z80.c (is_overflow): Avoid too large shift.

View File

@ -1722,7 +1722,7 @@ add_to_result (expressionS *resultP, offsetT amount, int rhs_highbit)
valueT ures = resultP->X_add_number;
valueT uamount = amount;
resultP->X_add_number += amount;
resultP->X_add_number += uamount;
resultP->X_extrabit ^= rhs_highbit;
@ -1738,7 +1738,7 @@ subtract_from_result (expressionS *resultP, offsetT amount, int rhs_highbit)
valueT ures = resultP->X_add_number;
valueT uamount = amount;
resultP->X_add_number -= amount;
resultP->X_add_number -= uamount;
resultP->X_extrabit ^= rhs_highbit;