This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH committed] Fix part of PR78555 - gcc/real.c:2890:25: runtime error: left shift of negative value -125
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 Nov 2016 13:27:24 +0100
- Subject: [PATCH committed] Fix part of PR78555 - gcc/real.c:2890:25: runtime error: left shift of negative value -125
- Authentication-results: sourceware.org; auth=none
bootstrap-ubsan gcc shows:
gcc/real.c:2890:25: runtime error: left shift of negative value -125
Fixed by casting to unsigned.
Tested on ppc64le. Committed as obvious.
PR ipa/78555
* real.c (real_hash): Add cast to avoid left
shifting of negative values.
diff --git a/gcc/real.c b/gcc/real.c
index 66e88e2ad366..eabe22de8510 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -2887,7 +2887,7 @@ real_hash (const REAL_VALUE_TYPE *r)
return h;
case rvc_normal:
- h |= REAL_EXP (r) << 3;
+ h |= (unsigned int)REAL_EXP (r) << 3;
break;
case rvc_nan:
--
Markus