summaryrefslogtreecommitdiff
path: root/test/regression/sizeof1.c
blob: e8441a2c03277b55bd0ef19c5be2ecadb471794b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
struct s {
  char c;
  union { int i[3]; double d; } n;
  struct { struct s * hd; struct s * tl; } l;
};

char tbl[sizeof(struct s)];
/* Should be 32:
      char c  at 0
      union n at 8 because alignment = 8; sizeof = 12
      struct l at 8+12=20 with alignment = 4; sizeof = 8
      end of struct at 20+8=28
      alignment of whole struct is 8 because of d
      28 aligned to 8 -> 32
*/

struct bits1 {
  unsigned a: 1;
  unsigned b: 6;
};

char b1[sizeof(struct bits1)];  /* should be 1 */

struct bits2 {
  unsigned a: 1;
  unsigned b: 6;
  unsigned c: 28;
};

char b2[sizeof(struct bits2)];  /* should be 8 */