This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Pointer extension bug on 64 bit systems.
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 7 Apr 2003 10:27:42 -0700 (PDT)
- Subject: Pointer extension bug on 64 bit systems.
- Reply-to: sje at cup dot hp dot com
This is a patch for a bug in expr.c where offsets (and a size value) are
extended to Pmode using convert_memory_address, but the values being
extended are not addresses, they are either offsets or, in one case, the
size of something being copied.
In these cases we should extend the values to Psize using sign extension
and not do it with convert_memory_address because the values in question
are not memory addresses and convert_memory_address may do the wrong
type of value extension depending on what the value of
POINTERS_EXTEND_UNSIGNED is.
Since these changes are all under the POINTERS_EXTEND_UNSIGNED macro it
should only affect the IA64 HP-UX platform, Alpha, and Sparc. Alpha
shouldn't see a difference because it uses sign extension to extend
pointers anyway and that is what I changed the code to do in all cases.
Tested on IA64 HP-UX where it fixes a bootstrap problem I was having.
I would like to check this in on the main line and on the 3.3 branch if
approved.
2003-04-07 Steve Ellcey <sje at cup dot hp dot com>
* expr.c (expand_assignment): Extend offset_rtx with convert_to_mode
not with convert_memory_address.
(store_constructor): Ditto, and same for copy_size_rtx.
(expand_expr): Ditto.
*** gcc.orig/gcc/expr.c Mon Apr 7 10:09:02 2003
--- gcc/gcc/expr.c Mon Apr 7 10:11:27 2003
*************** expand_assignment (to, from, want_value,
*** 4063,4069 ****
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_memory_address (Pmode, offset_rtx);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
--- 4063,4069 ----
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_to_mode (Pmode, offset_rtx, 0);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
*************** store_expr (exp, target, want_value)
*** 4592,4599 ****
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (copy_size_rtx) != Pmode)
! copy_size_rtx = convert_memory_address (Pmode,
! copy_size_rtx);
#endif
target = offset_address (target, copy_size_rtx,
--- 4592,4598 ----
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (copy_size_rtx) != Pmode)
! copy_size_rtx = convert_to_mode (Pmode, copy_size_rtx, 0);
#endif
target = offset_address (target, copy_size_rtx,
*************** store_constructor (exp, target, cleared,
*** 4900,4906 ****
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_memory_address (Pmode, offset_rtx);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
--- 4899,4905 ----
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_to_mode (Pmode, offset_rtx, 0);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
*************** expand_expr (exp, target, tmode, modifie
*** 7382,7388 ****
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_memory_address (Pmode, offset_rtx);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
--- 7381,7387 ----
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
! offset_rtx = convert_to_mode (Pmode, offset_rtx, 0);
#else
if (GET_MODE (offset_rtx) != ptr_mode)
offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);