chibicc/test/union.c

13 lines
407 B
C

#include "test.h"
int main() {
ASSERT(8, ({ union { int a; char b[6]; } x; sizeof(x); }));
ASSERT(3, ({ union { int a; char b[4]; } x; x.a = 515; x.b[0]; }));
ASSERT(2, ({ union { int a; char b[4]; } x; x.a = 515; x.b[1]; }));
ASSERT(0, ({ union { int a; char b[4]; } x; x.a = 515; x.b[2]; }));
ASSERT(0, ({ union { int a; char b[4]; } x; x.a = 515; x.b[3]; }));
printf("OK\n");
return 0;
}