agg_union.c (507B)
1 /* A union: storing through one member and reading the overlapping bytes through 2 * a wider member. Exercises overlapping-storage loads/stores at the same offset 3 * with different widths. Little-endian AArch64: bytes {42,0,0,0} written as an 4 * int read as the low byte = 42. The high bytes are zero-initialized. */ 5 union U { 6 unsigned char bytes[4]; 7 unsigned word; 8 }; 9 int test_main(void) { 10 volatile unsigned char lo = 42; 11 union U u; 12 u.word = 0; 13 u.bytes[0] = lo; 14 return (int)(u.word & 0xff); 15 }