2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / align-6.c
blob3364746fb277d46033d1c5829e48960770fb87e3
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 -fsanitize-recover=alignment" } */
5 struct S { int a; char b; long long c; short d[10]; };
6 struct T { char a; long long b; };
7 struct U { char a; int b; int c; long long d; struct S e; struct T f; } __attribute__((packed));
8 struct V { long long a; struct S b; struct T c; struct U u; } v;
10 __attribute__((noinline, noclone)) int
11 foo (struct S *p)
13 volatile int i;
14 i = p->a;
15 i = p->a;
16 i = p->a;
17 i = p->a;
18 return p->a;
21 int
22 main ()
24 if (foo (&v.u.e))
25 __builtin_abort ();
26 return 0;
29 /* { dg-output "\.c:14:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
30 /* { dg-output "\.c:15:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
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-output "\.c:17:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
33 /* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment" } */