diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2018-01-25 08:49:33 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2018-01-25 08:49:33 +0000 |
commit | 8bbc33baa40010c8f5ca1af9b8bfffd67ae654ad (patch) | |
tree | c5e2748190eff9453ae08b9117c4c546c48cc539 /gcc/testsuite/c-c++-common/asan/memcmp-1.c | |
parent | 03ac50856c9fc8c96b7a17239ee40a10397750a7 (diff) | |
download | gcc-tarball-8bbc33baa40010c8f5ca1af9b8bfffd67ae654ad.tar.gz |
Diffstat (limited to 'gcc/testsuite/c-c++-common/asan/memcmp-1.c')
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/memcmp-1.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc/testsuite/c-c++-common/asan/memcmp-1.c new file mode 100644 index 0000000000..5915988be5 --- /dev/null +++ b/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[] = {(char)one, 2, 3, 4}; + char a2[] = {1, (char)(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_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ |