> From: Andreas Schwab [mailto:schwab@linux-m68k.org] > > This adds a full byte of padding between each bitfield. If you want a > single padding bit you should use :1, but you also need to update the > test to check for 0x44434241 (0x88868482 is impossible, since that > requires at least 8 bits per bitfield). Actually if I understood C99 correctly it depends on the storage unit allocated for the bitfield preceding the 0 length bitfield. Instead of trying to cover all possible value read from this bitfield I rewrote the test to check if bswap misinterpret the expression and replace it with a load or load+bswap. This reduce the number of possible values to 2 and thus makes the test less fragile and easier to understand. By the way, I couldn't understand how you reached the value 0x44434241. Can you explain me? Here is the ChangeLog: 2014-05-29 Thomas Preud'homme * gcc.c-torture/execute/bswap-2.c: Add alignment constraints to bitfield and test wrong results instead of correct results to make the test more portable. And the patch: diff --git a/gcc/testsuite/gcc.c-torture/execute/bswap-2.c b/gcc/testsuite/gcc.c-torture/execute/bswap-2.c index 38f18fd..a47e01a 100644 --- a/gcc/testsuite/gcc.c-torture/execute/bswap-2.c +++ b/gcc/testsuite/gcc.c-torture/execute/bswap-2.c @@ -6,8 +6,11 @@ typedef __UINT32_TYPE__ unsigned; struct bitfield { unsigned char f0:7; + unsigned char :1; unsigned char f1:7; + unsigned char :1; unsigned char f2:7; + unsigned char :1; unsigned char f3:7; }; @@ -74,11 +77,17 @@ main () return 0; bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 }; out = partial_read_le32 (bfin); - if (out != 0x09070503 && out != 0x88868482 && out != 0x78306141) + /* Test what bswap would do if its check are not strict enough instead of + what is the expected result as there is too many possible results with + bitfields. */ + if (out == 0x89878583) __builtin_abort (); bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 }; out = partial_read_be32 (bfin); - if (out != 0x03050709 && out != 0x82848688 && out != 0x41613078) + /* Test what bswap would do if its check are not strict enough instead of + what is the expected result as there is too many possible results with + bitfields. */ + if (out == 0x83858789) __builtin_abort (); out = fake_read_le32 (cin, &cin[2]); if (out != 0x89018583) Best regards, Thomas