1/* Limit this to known non-strict alignment targets.  */
2/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */
3/* { dg-options "-O -fsanitize=alignment -fno-sanitize-recover=alignment -fdump-tree-sanopt-details" } */
4/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
5/* { dg-shouldfail "ubsan" } */
6
7struct S { int a; char b; long long c; short d[10]; };
8struct T { char a; long long b; };
9struct U { char a; int b; int c; long long d; struct S e; struct T f; } __attribute__((packed));
10struct V { long long a; struct S b; struct T c; struct U u; } v;
11
12__attribute__((noinline, noclone)) int
13foo (struct S *p)
14{
15  volatile int i;
16  i = p->a;
17  i = p->a;
18  i = p->a;
19  i = p->a;
20  return p->a;
21}
22
23int
24main ()
25{
26  if (foo (&v.u.e))
27    __builtin_abort ();
28  return 0;
29}
30
31/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
32/* { dg-final { scan-tree-dump-times "Optimizing" 4 "sanopt"} } */
33/* { dg-final { cleanup-tree-dump "sanopt" } } */
34