This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
expand_assignment bugfix
- To: egcs-patches at egcs dot cygnus dot com
- Subject: expand_assignment bugfix
- From: Jeffrey A Law <law at upchuck dot cygnus dot com>
- Date: Tue, 23 Mar 1999 23:21:52 -0700
- Reply-To: law at cygnus dot com
Consider this C++ source:
struct RAM
{
int spare [3];
};
void monk ()
{
int i = 0;
(*(RAM*)0).spare [i] = 0;
}
We end up with a memory reference like (mem:BLK (const_int 0))
Note the CONST_INT has VOIDmode. Calling force_reg to force the value into
a VOIDmode register loses.
* expr.c (expand_assignment): Do not try to optimize a aggregate
address which has VOIDmode.
Index: expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.c,v
retrieving revision 1.131
diff -c -3 -p -r1.131 expr.c
*** expr.c 1999/03/19 14:26:50 1.131
--- expr.c 1999/03/24 06:28:38
*************** expand_assignment (to, from, want_value,
*** 3276,3283 ****
--- 3276,3286 ----
#endif
}
+ /* A constant address in TO_RTX can have VOIDmode, we must not try
+ to call force_reg for that case. Avoid that case. */
if (GET_CODE (to_rtx) == MEM
&& GET_MODE (to_rtx) == BLKmode
+ && GET_MODE (XEXP (to_rtx, 0)) != VOIDmode
&& bitsize
&& (bitpos % bitsize) == 0
&& (bitsize % GET_MODE_ALIGNMENT (mode1)) == 0