| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-shouldfail "asan" } */ |
| 3 |
|
| 4 |
#include <assert.h> |
| 5 |
|
| 6 |
struct A { |
| 7 |
char a[3]; |
| 8 |
int b[3]; |
| 9 |
}; |
| 10 |
|
| 11 |
volatile int ten = 10; |
| 12 |
|
| 13 |
__attribute__((noinline)) void foo(int index, int len) { |
| 14 |
volatile struct A str[len] __attribute__((aligned(32))); |
| 15 |
assert(!((long) str & 31L)); |
| 16 |
str[index].a[0] = '1'; // BOOM |
| 17 |
} |
| 18 |
|
| 19 |
int main(int argc, char **argv) { |
| 20 |
foo(ten, ten); |
| 21 |
return 0; |
| 22 |
} |
| 23 |
|
| 24 |
/* { dg-output "WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */ |
| 25 |
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*foo(\[^\n\r]*alloca_detect_custom_size.c:16|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ |
| 26 |
/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */ |
| 27 |
/* { dg-output "\[^\n\r]*in foo.*alloca_detect_custom_size.c.*(\n|\r\n|\r)" */ |