This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix signed overflow for zext_hwi (..., 63)


...well, still HOST_BITS_PER_WIDE_INT-1 officially, until Richard's patches.

Caught by a boostrap-ubsan on wide-int.  Tested on x86_64-linux-gnu and
committed as obvious.

Richard


gcc/
	* hwint.h (zext_hwi): Fix signed overflow for prec == 63.

Index: gcc/hwint.h
===================================================================
--- gcc/hwint.h	2014-01-03 15:06:18.841058787 +0000
+++ gcc/hwint.h	2014-05-02 16:31:44.987263123 +0100
@@ -344,7 +344,7 @@ zext_hwi (unsigned HOST_WIDE_INT src, un
   else
     {
       gcc_checking_assert (prec < HOST_BITS_PER_WIDE_INT);
-      return src & (((HOST_WIDE_INT) 1 << prec) - 1);
+      return src & (((unsigned HOST_WIDE_INT) 1 << prec) - 1);
     }
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]