| 1 |
// { dg-do run } |
| 2 |
// { dg-shouldfail "asan" } |
| 3 |
// { dg-additional-options "-Wno-psabi" } |
| 4 |
|
| 5 |
// On SPARC 32-bit, only vectors up to 8 bytes are passed in registers |
| 6 |
#if defined(__sparc__) && !defined(__sparcv9) && !defined(__arch64__) |
| 7 |
#define SMALL_VECTOR |
| 8 |
#endif |
| 9 |
|
| 10 |
#ifdef SMALL_VECTOR |
| 11 |
typedef int v4si __attribute__ ((vector_size (8))); |
| 12 |
#else |
| 13 |
typedef int v4si __attribute__ ((vector_size (16))); |
| 14 |
#endif |
| 15 |
|
| 16 |
static __attribute__ ((noinline)) int |
| 17 |
goo (v4si *a) |
| 18 |
{ |
| 19 |
return (*(volatile v4si *) (a + 1))[2]; |
| 20 |
} |
| 21 |
|
| 22 |
__attribute__ ((noinline)) int |
| 23 |
foo (v4si arg) |
| 24 |
{ |
| 25 |
return goo (&arg); |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
main () |
| 30 |
{ |
| 31 |
#ifdef SMALL_VECTOR |
| 32 |
v4si v = {1,2}; |
| 33 |
#else |
| 34 |
v4si v = {1,2,3,4}; |
| 35 |
#endif |
| 36 |
return foo (v); |
| 37 |
} |
| 38 |
|
| 39 |
// { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow on address.*(\n|\r\n|\r)" } |
| 40 |
// { dg-output "READ of size . at.*" } |
| 41 |
// { dg-output ".*'arg' \\(line 23\\) <== Memory access at offset \[0-9\]* overflows this variable.*" } |