File: issue166b.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (20 lines) | stat: -rw-r--r-- 512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stddef.h>
#include <assert.h>
struct abc1 { int a, b, c; };
union abc2 { int a, b, c; };

typedef struct abc1 abc1;
typedef union abc2 abc2;

int main () {

assert(offsetof(abc1, a) == 0); // always, because there's no padding before a.
assert(offsetof(abc1, b) == 4); // here, on my system
assert(offsetof(abc2, a) == offsetof(abc2, b)); // (members overlap)

printf("%ld\n", offsetof(abc1, a) );
printf("%ld\n", offsetof(abc1, b) );
printf("%ld\n", offsetof(abc2, a) );
return 0;
}