OSDN Git Service

2004-06-13 Eric Christopher <echristo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pack-test-4.c
1 /* PR c/11885
2    Bug: flag4 was allocated into the same byte as the other flags.
3    { dg-options "" }
4    { dg-do run } */
5
6 typedef unsigned char uint8_t;
7
8 typedef struct {
9     uint8_t flag1:2;
10     uint8_t flag2:1;
11     uint8_t flag3:1;
12    
13     uint8_t flag4;
14
15 } __attribute__ ((packed)) MyType;
16
17 int main (void)
18 {
19   MyType a;
20   MyType *b = &a;
21
22   b->flag1 = 0;
23   b->flag2 = 0;
24   b->flag3 = 0;
25
26   b->flag4 = 0;
27
28   b->flag4++;
29     
30   if (b->flag1 != 0)
31     abort ();
32 }