PR c/64856
[official-gcc.git] / gcc / testsuite / gcc.dg / pack-test-4.c
blob1ad8ee4fb000dbb1d6f33e680e4a50c4f49f5711
1 /* PR c/11885
2 Bug: flag4 was allocated into the same byte as the other flags.
3 { dg-options "" }
4 { dg-do run } */
6 extern void abort (void);
8 typedef unsigned char uint8_t;
10 typedef struct {
11 uint8_t flag1:2;
12 uint8_t flag2:1;
13 uint8_t flag3:1;
15 uint8_t flag4;
17 } __attribute__ ((packed)) MyType;
19 int main (void)
21 MyType a;
22 MyType *b = &a;
24 b->flag1 = 0;
25 b->flag2 = 0;
26 b->flag3 = 0;
28 b->flag4 = 0;
30 b->flag4++;
32 if (b->flag1 != 0)
33 abort ();
35 return 0;