From acc2580750f930440cabe85650df8a2f20ff520d Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 22 Aug 2018 11:01:58 +0000 Subject: [PATCH] re PR tree-optimization/86988 (ICE: tree check: expected integer_cst, have var_decl in get_len, at tree.h:5563) 2018-08-22 Richard Biener PR tree-optimization/86988 * tree-vrp.c (vrp_prop::check_mem_ref): Bail out on VLAs. * g++.dg/pr86988.C: New testcase. From-SVN: r263762 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr86988.C | 16 ++++++++++++++++ gcc/tree-vrp.c | 1 + 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr86988.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a67b236a37..7dfdd45dd97 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-08-22 Richard Biener + + PR tree-optimization/86988 + * tree-vrp.c (vrp_prop::check_mem_ref): Bail out on VLAs. + 2018-08-22 Richard Biener PR tree-optimization/86945 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4e38d714ef4..e238d93825a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-22 Richard Biener + + PR tree-optimization/86988 + * g++.dg/pr86988.C: New testcase. + 2018-08-22 Richard Biener PR tree-optimization/86945 diff --git a/gcc/testsuite/g++.dg/pr86988.C b/gcc/testsuite/g++.dg/pr86988.C new file mode 100644 index 00000000000..62fb0f3220d --- /dev/null +++ b/gcc/testsuite/g++.dg/pr86988.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-O2 -Warray-bounds" } + +struct R { int r; }; +void baz (char *, char *, char *, char *); + +void +foo () +{ + const R a = { 12 }; + char b[1][a.r] = { { "12345678901" } }; + char c[a.r] = { "12345678901" }; + char d[1][a.r] = { { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' } }; + char e[a.r] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' }; + baz (b[0], c, d[0], e); +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 24e089b019b..ead19f15996 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4581,6 +4581,7 @@ vrp_prop::check_mem_ref (location_t location, tree ref, tree reftype = TREE_TYPE (arg); if (POINTER_TYPE_P (reftype) || !COMPLETE_TYPE_P (reftype) + || TREE_CODE (TYPE_SIZE_UNIT (reftype)) != INTEGER_CST || RECORD_OR_UNION_TYPE_P (reftype)) return; -- 2.30.2