public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong
@ 2014-07-23 13:33 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2014-07-23 13:33 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-23 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 13:33 [ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).