This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: alignment computed by get_inner_reference
- To: gcc-patches at gcc dot gnu dot org
- Subject: RFA: alignment computed by get_inner_reference
- From: Nick Clifton <nickc at redhat dot com>
- Date: Sun, 27 Aug 2000 13:21:21 -0700
Hi Guys,
I ran into a seg fault whilst running the gcc compile testcase
20000606-1.c for the arm-ellf toolchain. I have tracked down the
problem to what I believe to be a bug in get_inner_reference, but I
am not familiar enough with this code to be sure.
The problem is that get_inner_reference is return an alignment value
of 1 in the parameter 'palignment'. This alignment is supposed to
be in bits, so an alignment of 1 does not really make much sense.
The effect of returning this value is an infinite loop between
store_split_bit_field and store_fixed_bit_field in expmed.c.
The cause of the bug, I think, is that the code in
get_inner_reference uses the macros DECL_ALIGN and TYPE_ALIGN without
converting them from byte alignments to bit alignments. The patch
below fixes this (and allows the testcase to compile).
Is this patch OK to apply ?
Cheers
Nick
2000-08-27 Nick Clifton <nickc@redhat.com>
* expr.c (get_inner_reference): Convert DECL_ALIGN and
TYPE_ALIGN to bit alignments.
Index: gcc/expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.254
diff -p -r1.254 expr.c
*** expr.c 2000/08/24 20:31:31 1.254
--- expr.c 2000/08/27 20:14:48
*************** get_inner_reference (exp, pbitsize, pbit
*** 5162,5170 ****
}
if (DECL_P (exp))
! alignment = MIN (alignment, DECL_ALIGN (exp));
else if (TREE_TYPE (exp) != 0)
! alignment = MIN (alignment, TYPE_ALIGN (TREE_TYPE (exp)));
/* If OFFSET is constant, see if we can return the whole thing as a
constant bit position. Otherwise, split it up. */
--- 5162,5170 ----
}
if (DECL_P (exp))
! alignment = MIN (alignment, DECL_ALIGN (exp) * BITS_PER_UNIT);
else if (TREE_TYPE (exp) != 0)
! alignment = MIN (alignment, TYPE_ALIGN (TREE_TYPE (exp)) * BITS_PER_UNIT);
/* If OFFSET is constant, see if we can return the whole thing as a
constant bit position. Otherwise, split it up. */