This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] libobjc encoding fix
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: [PATCH] libobjc encoding fix
- From: Ovidiu Predescu <ovidiu at cup dot hp dot com>
- Date: Tue, 11 Apr 2000 14:03:31 -0700
- Cc: Richard Henderson <rth at cygnus dot com>, gcc-patches at gcc dot gnu dot org
Hi,
The patch is definitely not correct! The objc_layout_structure_next_member()
function computes the size and the alignment using 'prev_type' and not 'type'.
The code you removed is initializing prev_type and type to point to the right
values, which is obviously wrong.
I guess this initialization code could be done in objc_layout_structure()
function, but then the user programs should be written using a do/while
construction instead of a while construction.
Regards,
Ovidiu
On Tue, 11 Apr 2000 12:19:39 +0200, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> objc_layout_structure_next_member never considers the first field's
> alignment requirements which means that e.g. if a structure contains:
>
> struct A {
> char *p;
> char c;
> };
>
> then libobjc will compute wrong alignment and wrong size of that structure
> (it only considers p when counting the record_size, but because alignment of
> the first field is never considered, it means that it does not pad the size
> up to next alignment properly either.
> It shows up e.g. in bf-16.m test.
> I don't have tests from other platforms but sparc64 and sparc, but I don't
> think it works properly anywhere.
>
> 2000-04-11 Jakub Jelinek <jakub@redhat.com>
>
> * encoding.c (objc_layout_structure_next_member): Do the whole
> procedure even for the first member, so that we get correct
> alignment.
>
> --- libobjc/encoding.c.jj Sat Oct 17 00:19:21 1998
> +++ libobjc/encoding.c Tue Apr 11 11:42:57 2000
> @@ -743,15 +743,6 @@ objc_layout_structure_next_member (struc
> /* The current type without the type qualifiers */
> const char *type;
>
> -#if 1
> - if (layout->prev_type == NULL)
> - {
> - layout->prev_type = layout->type;
> - layout->type = objc_skip_typespec (layout->prev_type);
> - return YES;
> - }
> -#endif
> -
> /* Add the size of the previous field to the size of the record. */
> if (layout->prev_type)
> {
> @@ -760,7 +751,6 @@ objc_layout_structure_next_member (struc
> if (*type != _C_BFLD)
> layout->record_size += objc_sizeof_type (type) * BITS_PER_UNIT;
> else {
> - desired_align = 1;
> /* Get the bitfield's type */
> for (bfld_type = type + 1;
> isdigit(*bfld_type);
>
> Jakub
>