aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c')
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c b/gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c
new file mode 100644
index 000000000..c5907786f
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/asan/bitfield-3.c
@@ -0,0 +1,25 @@
+/* Check that Asan correctly instruments bitfields with round offset. */
+
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+struct A
+{
+ char base;
+ int : 8;
+ int x : 8;
+};
+
+int __attribute__ ((noinline, noclone))
+f (void *p) {
+ return ((struct A *)p)->x;
+}
+
+int
+main ()
+{
+ char a = 0;
+ return f (&a);
+}
+
+/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */