This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix signed overflow for zext_hwi (..., 63)
- From: Richard Sandiford <rsandifo at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 02 May 2014 16:36:47 +0100
- Subject: [committed] Fix signed overflow for zext_hwi (..., 63)
- Authentication-results: sourceware.org; auth=none
...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);
}
}