ubsan: expr.c:1725,1741 signed integer overflow
authorAlan Modra <amodra@gmail.com>
Wed, 2 Sep 2020 00:59:21 +0000 (10:29 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 2 Sep 2020 07:00:43 +0000 (16:30 +0930)
* expr.c (add_to_result, subtract_from_result): Use unsigned
addition and subtraction.

gas/ChangeLog
gas/expr.c

index 641b68de66afc67be53c275569540f504189c26f..004834f68c912c223f66a95766ca391fe54ad47c 100644 (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.
index da4fbcf8cd6821586c26c5fd470589a1c568c414..6f74de786d2297cb88ea6a84ff4c375a09c14639 100644 (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;