From: Sergei Trofimovich <sly...@inbox.ru>

From: Sergei Trofimovich <siarh...@google.com>

asan's test allocates 2 pages via pvalloc(kPageSize + 100)
and makes sure dereference of 'kPageSize + 101' does not
trigger asan checks.

glibc's and gcc's malloc-like attribute checkers trigger
a warning:
    asan_test.cc:129:22: error: writing 1 byte into a region
    of size 0 [-Werror=stringop-overflow=]

As there is no easy way to convey pvalloc()'s granularity
to gcc let's just disable the warning for this test.

        * g++.dg/asan/asan_test.C: disable -Wstringop-overflow.
---
 gcc/testsuite/ChangeLog               | 4 ++++
 gcc/testsuite/g++.dg/asan/asan_test.C | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9a87cfe595b..847b73e7287 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-24  Sergei Trofimovich <siarh...@google.com>
+
+       * g++.dg/asan/asan_test.C: disable -Wstringop-overflow.
+
 2020-01-22  Andrew Pinski  <apin...@marvell.com>
 
        * tree-ssa.exp: Set DEFAULT_VECTCFLAGS and DEFAULT_VECTCFLAGS.
diff --git a/gcc/testsuite/g++.dg/asan/asan_test.C 
b/gcc/testsuite/g++.dg/asan/asan_test.C
index f3f7626ef3b..8e18744c7c6 100644
--- a/gcc/testsuite/g++.dg/asan/asan_test.C
+++ b/gcc/testsuite/g++.dg/asan/asan_test.C
@@ -2,7 +2,7 @@
 // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } }
 // { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
 // { dg-additional-sources "asan_globals_test-wrapper.cc" }
-// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -g 
-DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 
-DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
+// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror 
-Wno-stringop-overflow -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 
-DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
 // { dg-additional-options "-DASAN_NEEDS_SEGV=1" { target { ! arm*-*-* } } }
 // { dg-additional-options "-DASAN_LOW_MEMORY=1 -DASAN_NEEDS_SEGV=0" { target 
arm*-*-* } }
 // { dg-additional-options "-DASAN_AVOID_EXPENSIVE_TESTS=1" { target { ! 
run_expensive_tests } } }
-- 
2.25.0

Reply via email to