This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][4.3][RFT] Fix PR37868, backport some PTA fixes
- From: Richard Guenther <rguenther at suse dot de>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Dec 2008 11:24:53 +0100 (CET)
- Subject: Re: [PATCH][4.3][RFT] Fix PR37868, backport some PTA fixes
- References: <alpine.LNX.1.10.0810222022520.3746@zhemvz.fhfr.qr> <200812031112.44087.ebotcazou@adacore.com>
On Wed, 3 Dec 2008, Eric Botcazou wrote:
> > --- gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pr37868.c 2008-10-22
> > 15:28:30.000000000 +0200 ***************
> > *** 0 ****
> > --- 1,28 ----
> > + /* { dg-do run } */
> > + /* { dg-options "-fno-strict-aliasing" } */
> > +
> > + extern void abort (void);
> > +
> > + struct X {
> > + unsigned char pad : 4;
> > + unsigned int a : 32;
> > + unsigned int b : 24;
> > + unsigned int c : 6;
> > + } __attribute__((packed));
> > +
> > + int main (void)
> > + {
> > + struct X x;
> > + unsigned int bad_bits;
> > +
> > + x.pad = -1;
> > + x.a = -1;
> > + x.b = -1;
> > + x.c = -1;
> > +
> > + bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x);
> > + if (bad_bits != 0)
> > + abort ();
> > + return 0;
> > + }
> > +
>
> Any particular reason for the __attribute__((packed)) on the structure? This
> causes it to be given alignment 8 so
>
> *(unsigned int *) &x
>
> may raise SIGBUS on strict-alignment platforms (e.g. SPARC). Removing it
> shouldn't change the internal layout and is sufficient since the structure
> contains 'unsigned int' bitfields.
I think dependent on ABI the char bitfield may not be packed together
with the int bitfields. But, if you can check a 4.3 version without the
backported fix and simply replacing the char bitfield with an integer
one (that shouldn't change the bug) and it still breaks such a change
would be fine (and then obviously the packed attribute can be removed).
Thanks,
Richard.