Hi, When creating static bounds for foo below we end up with:
*((unsigned long *) &__chkp_bounds_of_foo + 8) = ~(__builtin_ia32_sizeof (foo) + ((long unsigned int) &foo + 18446744073709551615)); This fails in gimplify_function_tree with gcc_assert (!VOID_TYPE_P (TREE_TYPE (*expr_p))); Is it OK? gcc/ChangeLog: 2017-04-04 Alexander Ivchenko <aivch...@gmail.com> * tree-chkp.c (chkp_get_bounds_for_decl_addr): assigning zero bounds to void variables gcc/testsuite/ChangeLog: 2017-04-04 Alexander Ivchenko <aivch...@gmail.com> * gcc.target/i386/mpx/PR79987.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/mpx/PR79987.c b/gcc/testsuite/gcc.target/i386/mpx/PR79987.c new file mode 100644 index 0000000..14a32f3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/PR79987.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +extern void foo; +void *bar = &foo; diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index b1ff218..8a16025 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3146,6 +3146,11 @@ chkp_get_bounds_for_decl_addr (tree decl) && !flag_chkp_incomplete_type) return chkp_get_zero_bounds (); + /* For void variables use zero bounds as well - we cannot + possibly get the size of the void. */ + if (VOID_TYPE_P (TREE_TYPE (decl))) + return chkp_get_zero_bounds (); + if (flag_chkp_use_static_bounds && VAR_P (decl) && (TREE_STATIC (decl)