diff mbox series

[testsuite,PR83612] Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c

Message ID 33a6fb61-daac-0ab1-5e80-c698961a9d31@mentor.com
State New
Headers show
Series [testsuite,PR83612] Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c | expand

Commit Message

Tom de Vries Dec. 30, 2017, 10:54 a.m. UTC
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
diff mbox series

Patch

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)