| 1 |
// { dg-do run } |
| 2 |
// { dg-shouldfail "asan" } |
| 3 |
// { dg-options "-fsanitize=address -fno-sanitize-address-use-after-scope" } |
| 4 |
|
| 5 |
struct A |
| 6 |
{ |
| 7 |
int a[5]; |
| 8 |
}; |
| 9 |
|
| 10 |
static __attribute__ ((noinline)) int |
| 11 |
goo (A *a) |
| 12 |
{ |
| 13 |
int *ptr = &a->a[0]; |
| 14 |
return *(volatile int *) (ptr - 1); |
| 15 |
} |
| 16 |
|
| 17 |
__attribute__ ((noinline)) int |
| 18 |
foo (A arg) |
| 19 |
{ |
| 20 |
return goo (&arg); |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
main () |
| 25 |
{ |
| 26 |
return foo (A ()); |
| 27 |
} |
| 28 |
|
| 29 |
// { dg-output "ERROR: AddressSanitizer: stack-buffer-underflow on address.*(\n|\r\n|\r)" } |
| 30 |
// { dg-output "READ of size . at.*" } |
| 31 |
// { dg-output ".*'arg' \\(line 18\\) <== Memory access at offset \[0-9\]* underflows this variable.*" } |