summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Baravy <i.baravy@samsung.com>2017-02-21 21:26:42 +0300
committerIvan Baravy <i.baravy@samsung.com>2017-02-21 21:26:42 +0300
commite78e2d435e263b7349a4157d6604e342bf6baed9 (patch)
tree7b40fc91cef094572d1322c12b25c005b9c2c194
parent74101f42c25667387723001937a017ebc2177828 (diff)
downloadlinaro-gcc-e78e2d435e263b7349a4157d6604e342bf6baed9.tar.gz
linaro-gcc-e78e2d435e263b7349a4157d6604e342bf6baed9.tar.bz2
linaro-gcc-e78e2d435e263b7349a4157d6604e342bf6baed9.zip
* gcc.dg/ubsan/static-init-null.c: New testcase
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/static-init-null.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ubsan/static-init-null.c b/gcc/testsuite/gcc.dg/ubsan/static-init-null.c
new file mode 100644
index 00000000000..678e33c2663
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/static-init-null.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=null" } */
+
+typedef struct a_s a_t;
+typedef struct b_s b_t;
+
+struct b_s
+{
+ int n;
+};
+
+struct a_s
+{
+ int n;
+};
+
+static a_t arr[] = {
+ {
+ .n = 1,
+ },
+};
+
+__attribute__ ((used)) static b_t inited_struct = {
+ .n = arr == 0 ? 0 : 16 / sizeof (arr[0]),
+};