diff mbox

Fix undefined behaviour in combine.c:force_to_mode

Message ID 201207071230.q67CU9hN026246@d06av02.portsmouth.uk.ibm.com
State Accepted
Headers show

Commit Message

Ulrich Weigand July 7, 2012, 12:30 p.m. UTC
http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00246.html

ChangeLog:

	* combine.c (force_to_mode) [LSHIFTRT]: Avoid undefined behaviour
	due to negative shift amount.
diff mbox

Patch

=== modified file 'gcc/combine.c'
--- gcc/combine.c	2012-02-22 12:22:43 +0000
+++ gcc/combine.c	2012-07-03 19:46:18 +0000
@@ -8432,6 +8432,7 @@ 
 	 in OP_MODE.  */
 
       if (CONST_INT_P (XEXP (x, 1))
+	  && INTVAL (XEXP (x, 1)) >= 0
 	  && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT
 	  && HWI_COMPUTABLE_MODE_P (op_mode))
 	{