| 1 |
// { dg-do run } |
| 2 |
// { dg-shouldfail "asan" } |
| 3 |
|
| 4 |
int *ptr; |
| 5 |
|
| 6 |
__attribute__((always_inline)) |
| 7 |
inline static void |
| 8 |
foo(int v) |
| 9 |
{ |
| 10 |
int values[10]; |
| 11 |
for (unsigned i = 0; i < 10; i++) |
| 12 |
values[i] = v; |
| 13 |
|
| 14 |
ptr = &values[3]; |
| 15 |
} |
| 16 |
|
| 17 |
int |
| 18 |
main (int argc, char **argv) |
| 19 |
{ |
| 20 |
foo (argc); |
| 21 |
|
| 22 |
return *ptr; |
| 23 |
} |
| 24 |
|
| 25 |
// { dg-output "ERROR: AddressSanitizer: stack-use-after-scope on address.*(\n|\r\n|\r)" } |
| 26 |
// { dg-output "READ of size 4 at.*" } |
| 27 |
// { dg-output ".*'values' \\(line 10\\) <== Memory access at offset \[0-9\]* is inside this variable.*" } |