diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/asan/memcmp-1.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/c-c++-common/asan/memcmp-1.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/asan/memcmp-1.c new file mode 100644 index 000000000..03f32e92a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/asan/memcmp-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-fno-builtin-memcmp" } */ +/* { dg-shouldfail "asan" } */ + +#include <string.h> + +volatile int one = 1; + +int +main () +{ + char a1[] = {one, 2, 3, 4}; + char a2[] = {1, 2*one, 3, 4}; + int res = memcmp (a1, a2, 5 + one); + return res; +} + +/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow.*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)memcmp |\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ |