This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong


Jakub reported to me that bounds-2.c test fails with
-fstack-protector-strong -Os.  The following hack fixes it.

Tested x86_64-linux, applying to trunk as obvious.

2014-07-23  Marek Polacek  <polacek@redhat.com>

	* c-c++-common/ubsan/bounds-2.c (fn4): Adjust to check the array size
	in the structure. 

diff --git gcc/testsuite/c-c++-common/ubsan/bounds-2.c gcc/testsuite/c-c++-common/ubsan/bounds-2.c
index 7ef71aa..73229dc 100644
--- gcc/testsuite/c-c++-common/ubsan/bounds-2.c
+++ gcc/testsuite/c-c++-common/ubsan/bounds-2.c
@@ -4,6 +4,7 @@
 /* Test runtime errors.  */
 
 struct S { int a[10]; };
+struct T { int a[5]; int s[2]; };
 
 int
 foo_5 (void)
@@ -47,8 +48,9 @@ fn3 (void)
 static void __attribute__ ((noinline, noclone))
 fn4 (void)
 {
-  volatile int a[5];
-  a[foo_5 ()] = 1;
+  struct T t;
+  asm ("" : : "r" (&t.a) : "memory");
+  t.a[foo_5 ()] = 1;
 }
 
 static void __attribute__ ((noinline, noclone))

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]