Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/20010518-2.c

raw
1 /* Mis-aligned packed structures. */
2
3 void abort (void);
4 void exit (int);
5
6 typedef struct
7 {
8 char b0;
9 char b1;
10 char b2;
11 char b3;
12 char b4;
13 char b5;
14 } __attribute__ ((packed)) b_struct;
15
16
17 typedef struct
18 {
19 short a;
20 long b;
21 short c;
22 short d;
23 b_struct e;
24 } __attribute__ ((packed)) a_struct;
25
26
27 int
28 main(void)
29 {
30 volatile a_struct *a;
31 volatile a_struct b;
32
33 a = &b;
34 *a = (a_struct){1,2,3,4};
35 a->e.b4 = 'c';
36
37 if (a->a != 1 || a->b != 2 || a->c != 3 || a->d != 4 || a->e.b4 != 'c')
38 abort ();
39
40 exit (0);
41 }