This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
expr.c: exapnd_expr() assumes TARGET bytes same as HOST bytes?
- To: gcc at gcc dot gnu dot org
- Subject: expr.c: exapnd_expr() assumes TARGET bytes same as HOST bytes?
- From: Alan Lehotsky <apl at alum dot mit dot edu>
- Date: Thu, 19 Jul 2001 15:11:01 -0400
In expand_expr(), the following
/* Fold an expression like: "foo"[2].
This is not done in fold so it won't happen inside &.
Don't fold if this is for wide characters since it's too
difficult to do correctly and this is a very rare case. */
if (modifier != EXPAND_CONST_ADDRESS && modifier != EXPAND_INITIALIZER
&& TREE_CODE (array) == STRING_CST
&& TREE_CODE (index) == INTEGER_CST
&& compare_tree_int (index, TREE_STRING_LENGTH (array)) < 0
&& GET_MODE_CLASS (mode) == MODE_INT
&& GET_MODE_SIZE (mode) == 1)
return
GEN_INT (TREE_STRING_POINTER (array)[TREE_INT_CST_LOW (index)]);
assumes that the HOST machine's bytes are the same size as the
target's bytes. Cross compiling for a machine with 32 bit bytes
from a SPARC causes me to generate bad code for the executable test
921218-1.c because the SPARC sign-extends the fetched byte \0377.
I'm not quite sure if the fix for this should just zero-or-sign
extend the character according to the value of DEFAULT_SIGNED_CHAR, or
if something more complex is required.
Any opinions?
-- Al