This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[testsuite, PR83612] Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 30 Dec 2017 11:54:39 +0100
- Subject: [testsuite, PR83612] Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c
- Authentication-results: sourceware.org; auth=none
Hi,
I ran into the following failure:
...
FAIL: gcc.dg/ubsan/object-size-9.c -O2 output pattern test, is
gcc.dg/ubsan/object-size-9.c:11:13: runtime error: load of address
0x000000600ff2 with insufficient space for an object of type 'char'
0x000000600ff2: note: pointer points here
<memory cannot be printed>
...
The failure is because the test-case expects the sanitizer to access the
memory and print its contents, but the memory happens not to be not
accessible.
I've applied the same fix as was applied in
c-c++-common/ubsan/object-size-9.c for PR sanitizer/64078: add an
alignment attribute to the variable to ensure that the memory after the
variable is accessible.
Tested on x86_64.
Committed as obvious.
Thanks,
- Tom
Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c
2017-12-30 Tom de Vries <tom@codesourcery.com>
PR testsuite/83612
* gcc.dg/ubsan/object-size-9 (t): Add alignment attribute.
---
gcc/testsuite/gcc.dg/ubsan/object-size-9.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/testsuite/gcc.dg/ubsan/object-size-9.c b/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
index e0a2980..41c4a94 100644
--- a/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
+++ b/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
@@ -3,7 +3,7 @@
/* { dg-options "-fsanitize=undefined" } */
struct T { int c; char d[]; };
-struct T t = { 1, "a" };
+struct T t __attribute__ ((aligned(4096))) = { 1, "a" };
int
baz (int i)