summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/asan/memcmp-1.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2018-01-25 08:49:33 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2018-01-25 08:49:33 +0000
commit8bbc33baa40010c8f5ca1af9b8bfffd67ae654ad (patch)
treec5e2748190eff9453ae08b9117c4c546c48cc539 /gcc/testsuite/c-c++-common/asan/memcmp-1.c
parent03ac50856c9fc8c96b7a17239ee40a10397750a7 (diff)
downloadgcc-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.c20
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)" } */