File: main.c

package info (click to toggle)
cbmc 4.9-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 40,588 kB
  • ctags: 19,198
  • sloc: cpp: 185,860; ansic: 16,162; yacc: 5,343; lex: 4,518; makefile: 954; pascal: 506; sh: 318; perl: 213; java: 206
file content (52 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define STATIC_ASSERT(condition) \
  int some_array##__LINE__[(condition) ? 1 : -1]

struct Z1
{
  char ch;
  int i:3;
  char ch2;
  // there is end-of-struct padding because of the int
} z1;

struct Z2
{
  char ch;
  char i:3;
  char ch2;
  // there is no end-of-struct padding
} z2;

struct Z3
{
  char ch;
  int i:3; // bit-fields do not get padding!
} z3;

struct Z4
{
  int i;
  long long int x; // pads to 8
  char ch; // 7 end-of-struct padding
} z4;

struct Z5
{
  char ch;
  long long int x[]; // pads to 8, but has no size
} z5;

STATIC_ASSERT(sizeof(struct Z1)==1+1+1+1);

#ifdef __GNUC__
STATIC_ASSERT(__builtin_offsetof(struct Z1, ch2)==2);
#endif

STATIC_ASSERT(sizeof(struct Z2)==1+1+1);
STATIC_ASSERT(sizeof(struct Z3)==1+1+2);
STATIC_ASSERT(sizeof(struct Z4)==4+4+8+1+7);
STATIC_ASSERT(sizeof(struct Z5)==8);

int main()
{
}