modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/20100430-1.c (about) 1 /* This used to generate unaligned accesses at -O2 because of IVOPTS. */ 2 3 struct packed_struct 4 { 5 struct packed_struct1 6 { 7 unsigned char cc11; 8 unsigned char cc12; 9 } __attribute__ ((packed)) pst1; 10 struct packed_struct2 11 { 12 unsigned char cc21; 13 unsigned char cc22; 14 unsigned short ss[104]; 15 unsigned char cc23[13]; 16 } __attribute__ ((packed)) pst2[4]; 17 } __attribute__ ((packed)); 18 19 typedef struct 20 { 21 int ii; 22 struct packed_struct buf; 23 } info_t; 24 25 static unsigned short g; 26 27 static void __attribute__((noinline)) 28 dummy (unsigned short s) 29 { 30 g = s; 31 } 32 33 static int 34 foo (info_t *info) 35 { 36 int i, j; 37 38 for (i = 0; i < info->buf.pst1.cc11; i++) 39 for (j = 0; j < info->buf.pst2[i].cc22; j++) 40 dummy (info->buf.pst2[i].ss[j]); 41 42 return 0; 43 } 44 45 int main(void) 46 { 47 info_t info; 48 info.buf.pst1.cc11 = 2; 49 info.buf.pst2[0].cc22 = info.buf.pst2[1].cc22 = 8; 50 return foo (&info); 51 }