This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C++ ABI fix - bitfield layout on IA-32


Jakub Jelinek wrote:
> 
> Hi!
> 
> The following patch fixes the 2002-06-17 introduced breakage
> when BIGGEST_FIELD_ALIGNMENT was killed.
> Unfortunately, the testcase still fails on the __alignof__ (x) != 4
> check (regression from 3.0.x and earlier) - this was apparently broken
> on gcc HEAD already in Nov 2001. Back into debugger.
> 
> Concerning __m64, I haven't seen anything done, but don't have icc
> to verify. The thread which talks about this is
> http://gcc.gnu.org/ml/gcc-patches/2002-06/msg01427.html
> 
> 2002-08-05  Jakub Jelinek  <jakub@redhat.com>
> 
>         * config/i386/i386.c (x86_field_alignment): Don't check
>         TARGET_ALIGN_DOUBLE for the second time.
>         Apply min for all MODE_INT and MODE_CLASS_INT modes.
> 
>         * g++.dg/abi/bitfield3.C: New test.
> 
> --- gcc/config/i386/i386.c.jj   2002-07-27 01:31:05.000000000 +0200
> +++ gcc/config/i386/i386.c      2002-08-05 13:31:53.000000000 +0200
> @@ -12644,10 +12644,9 @@ x86_field_alignment (field, computed)
>      return computed;
>    mode = TYPE_MODE (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE
>                     ? get_inner_array_type (field) : TREE_TYPE (field));
> -  if ((mode == DFmode || mode == DCmode
> -      || mode == DImode || mode == CDImode)
> -      && !TARGET_ALIGN_DOUBLE)
> +  if (mode == DFmode || mode == DCmode
> +      || GET_MODE_CLASS (mode) == MODE_INT
> +      || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
>      return MIN (32, computed);
>    return computed;
>  }
> -
> --- gcc/testsuite/g++.dg/abi/bitfield3.C.jj     2002-08-05 13:47:02.000000000 +0200
> +++ gcc/testsuite/g++.dg/abi/bitfield3.C        2002-08-05 13:44:52.000000000 +0200
> @@ -0,0 +1,21 @@
> +// Test for oversized bitfield alignment in structs on IA-32
> +// { dg-do run { i?86-*-* } }
> +// { dg-options "-O2" }
> +
> +struct A
> +{
> +  char a;
> +  int b : 224; // { dg-warning "exceeds its type" "" }
> +  char c;
> +} x;
> +
> +int main (void)
> +{
> +  if (&x.c - &x.a != 32)
> +    return 1;
> +  if (sizeof (x) != 36)
> +    return 2;
> +  if (__alignof__ (x) != 4)
> +    return 3;
> +  return 0;
> +}
Please make sure you get the same layout for
	struct A1 { char c; long long i;};
	struct A2 { char c; long long i : 64;};
in both C and C++. (And that you haven't changed the C ABI)

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]