| 1 |
/* { dg-do run { target { ilp32 || lp64 } } } */ |
| 2 |
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2 -Wno-address-of-packed-member" } } */ |
| 3 |
/* { dg-additional-options "-fno-omit-frame-pointer" { target *-*-darwin* } } */ |
| 4 |
/* { dg-shouldfail "asan" } */ |
| 5 |
|
| 6 |
struct S { int i; } __attribute__ ((packed)); |
| 7 |
|
| 8 |
__attribute__((noinline, noclone)) int |
| 9 |
foo (struct S *s) |
| 10 |
{ |
| 11 |
return s->i; |
| 12 |
} |
| 13 |
|
| 14 |
__attribute__((noinline, noclone)) int |
| 15 |
bar (int *s) |
| 16 |
{ |
| 17 |
return *s; |
| 18 |
} |
| 19 |
|
| 20 |
__attribute__((noinline, noclone)) struct S |
| 21 |
baz (struct S *s) |
| 22 |
{ |
| 23 |
return *s; |
| 24 |
} |
| 25 |
|
| 26 |
int |
| 27 |
main () |
| 28 |
{ |
| 29 |
struct T { char a[3]; struct S b[3]; char c; } t; |
| 30 |
int v = 5; |
| 31 |
struct S *p = t.b; |
| 32 |
asm volatile ("" : "+rm" (p)); |
| 33 |
p += 3; |
| 34 |
if (bar (&v) != 5) __builtin_abort (); |
| 35 |
volatile int w = foo (p); |
| 36 |
return 0; |
| 37 |
} |
| 38 |
|
| 39 |
/* { dg-output "ERROR: AddressSanitizer:\[^\n\r]*on address\[^\n\r]*" } */ |
| 40 |
/* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ |
| 41 |
/* { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ |
| 42 |
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*foo(\[^\n\r]*misalign-1.c:1\[01]|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ |
| 43 |
/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*misalign-1.c:3\[45]|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\]).*(\n|\r\n|\r)" } */ |