On Sat, May 02, 2015 at 10:03:13AM +0200, Jakub Jelinek wrote:
> On Fri, May 01, 2015 at 11:30:53PM -0400, tbsaunde+...@tbsaunde.org wrote:
> > +    AC_TRY_COMPILE(
> > +      [struct foo1 { char x; char :0; char y; };
> > +struct foo2 { char x; int :0; char y; };
> > +int foo1test[ sizeof (struct foo1) == 2 ? 1 : -1 ];
> > +int foo2test[ sizeof (struct foo2) == 5 ? 1 : -1]; ],
> 
> Shouldn't the 5 be sizeof (int) + 1?  I mean, we have targets with 16-bit
> ints.  I hope no target sizeof (int) == 1, that would break this test too
> (perhaps you could use long long  :0; instead?).

yeah, I just mindlessly ported the test program in tm.texi.  I'm dubious
anyone tries to use objective C on machines with 16 bit int, and doing
it on a machine with 8 bit int sounds insane, but who knows, and maybe
something else will need this test some day?

> Also, the anon bitfield changes alignment only on a subset of targets:
> targetm.align_anon_bitfield ()
> says if it makes a difference.

 the use of anon bitfields with width 0 seemed dubious to me without knowing
 about this.

> So, wouldn't it be better to test instead if
> struct C { char a; char b : 1; char c; };
> struct D { char a; long long b : 1; char c; };
> int footest[sizeof (struct C) < sizeof (struct D)] ? 1 : -1];
> ?  Tested that it works with powerpc compiler with -mbit-align vs.
> -mno-bit-align.

seems reasonable to me.

fwiw I committed the original patch last night since Andrew ok'd it, but
obviously we can improve it.  We should probably update the test in
tm.texi at the same time, or I guess better yet just refer to the m4
test there.

Trev

> 
>       Jakub

Reply via email to