diff options
author | Martin Sebor <msebor@redhat.com> | 2019-03-13 17:19:43 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-03-13 11:19:43 -0600 |
commit | 129ef157d4c0f369de9a5966b9f64bf9634e7d83 (patch) | |
tree | c07351ab0f320ecab251ed32f87f57451c977354 /gcc/tree-vrp.c | |
parent | bd8ea483131f0f92f10703d9ca00e5e8708d1d3c (diff) | |
download | gcc-129ef157d4c0f369de9a5966b9f64bf9634e7d83.zip gcc-129ef157d4c0f369de9a5966b9f64bf9634e7d83.tar.gz gcc-129ef157d4c0f369de9a5966b9f64bf9634e7d83.tar.bz2 |
PR tree-optimization/89662 - -Warray-bounds ICE on void* arithmetic
gcc/ChangeLog:
PR tree-optimization/89662
* tree-vrp.c (vrp_prop::check_mem_ref): Avoid assuming every type
has a size.
gcc/testsuite/ChangeLog:
PR tree-optimization/89662
* gcc.dg/Warray-bounds-41.c: New test.
From-SVN: r269655
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index bf1d947..1092fe0 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4718,13 +4718,16 @@ vrp_prop::check_mem_ref (location_t location, tree ref, { /* Extract the element type out of MEM_REF and use its size to compute the index to print in the diagnostic; arrays - in MEM_REF don't mean anything. */ + in MEM_REF don't mean anything. A type with no size like + void is as good as having a size of 1. */ tree type = TREE_TYPE (ref); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); - tree size = TYPE_SIZE_UNIT (type); - offrange[0] = offrange[0] / wi::to_offset (size); - offrange[1] = offrange[1] / wi::to_offset (size); + if (tree size = TYPE_SIZE_UNIT (type)) + { + offrange[0] = offrange[0] / wi::to_offset (size); + offrange[1] = offrange[1] / wi::to_offset (size); + } } else { |