combine.c (make_extraction): Avoid reference outside object.
authorIan Lance Taylor <ian@airs.com>
Fri, 26 Aug 2005 21:52:23 +0000 (21:52 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Fri, 26 Aug 2005 21:52:23 +0000 (21:52 +0000)
2005-08-26  Ian Lance Taylor  <ian@airs.com>

        * combine.c (make_extraction): Avoid reference outside object.

From-SVN: r103537

gcc/ChangeLog
gcc/combine.c

index 8d90f9c0a59b5cd5970e880c342e4afa23620883..9a810aa12dd28ca77e8cafa2c7aadf701db7a5c1 100644 (file)
@@ -1,3 +1,7 @@
+2005-08-26  Ian Lance Taylor  <ian@airs.com>
+
+       * combine.c (make_extraction): Avoid reference outside object.
+
 2005-08-26  J"orn Rennecke <joern.rennecke@st.com>
 
        * stor-layout.c (finalize_type_size): Restore behaviour for
index 5628e24f0452393fd23dba952c0dffccf0f0826b..57f490da76b94b68b031bd18c48a2304c99cb3ef 100644 (file)
@@ -6484,11 +6484,13 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos,
          && GET_MODE_SIZE (inner_mode) < GET_MODE_SIZE (is_mode))
        offset -= GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (inner_mode);
 
-      /* If this is a constant position, we can move to the desired byte.  */
+      /* If this is a constant position, we can move to the desired byte.
+        Be careful not to go beyond the original object. */
       if (pos_rtx == 0)
        {
-         offset += pos / BITS_PER_UNIT;
-         pos %= GET_MODE_BITSIZE (wanted_inner_mode);
+         enum machine_mode bfmode = smallest_mode_for_size (len, MODE_INT);
+         offset += pos / GET_MODE_BITSIZE (bfmode);
+         pos %= GET_MODE_BITSIZE (bfmode);
        }
 
       if (BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN