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][4.3][RFT] Fix PR37868, backport some PTA fixes


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.


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