public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix for PR79987
@ 2017-04-04 15:07 Alexander Ivchenko
  2017-04-04 15:34 ` Jeff Law
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Ivchenko @ 2017-04-04 15:07 UTC (permalink / raw)
  To: Ilya Enkovich, marxin; +Cc: GCC Patches

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  <aivchenk@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  <aivchenk@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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-09 17:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 15:07 Fix for PR79987 Alexander Ivchenko
2017-04-04 15:34 ` Jeff Law
2017-04-08 19:59   ` Ilya Enkovich
2017-05-09 15:41     ` Alexander Ivchenko
     [not found]       ` <CAMbmDYYj++Trk1JHs0dXBR4NfLCaKNnzLHN1PBF7a_96YCJGWg@mail.gmail.com>
     [not found]         ` <CACysShjZboYogD31Ujgt-xpE3jK2co1nUpEzxbbrSWbOV_Z4Tg@mail.gmail.com>
     [not found]           ` <CAMbmDYbHjZEXz3YcTvPQa950sxmR3fa+yYsCPkzhychFtjW4Cw@mail.gmail.com>
     [not found]             ` <CACysShip_WNDryk1kUiJCO0Mpc_8SVNRkByTdmzEC0xfxFuviw@mail.gmail.com>
2017-05-11 18:41               ` Ilya Enkovich
2017-06-09 12:22                 ` Alexander Ivchenko
2017-06-09 17:46                   ` Ilya Enkovich

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).