[ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong
Marek Polacek
polacek@redhat.com
Wed Jul 23 13:33:00 GMT 2014
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
More information about the Gcc-patches
mailing list