1 /* { dg-do compile } */
2 /* { dg-options "-Os -mno-unaligned-access" } */
3 /* { dg-final { scan-assembler "ldrb" } } */
4 /* { dg-final { scan-assembler "strb" } } */
5
6 struct s
7 {
8 char u;
9 long long v[2];
10 } __attribute__((packed,aligned(1)));
11
12 __attribute__((noinline, noclone))
foo(struct s * x,int y,long long z)13 long long foo(struct s *x, int y, long long z)
14 {
15 long long a = x->v[y];
16 x->v[y] = z;
17 return a;
18 }
19
20 struct s a = {0,{0,0}};
main()21 int main()
22 {
23 if (foo(&a,0,1) != 0)
24 __builtin_abort();
25 if (foo(&a,0,2) != 1)
26 __builtin_abort();
27 if (foo(&a,1,1) != 0)
28 __builtin_abort();
29 return 0;
30 }
31