aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Tietz <ktietz@redhat.com>2014-11-27 14:02:45 +0100
committerKai Tietz <ktietz@gcc.gnu.org>2014-11-27 14:02:45 +0100
commit4784470a7e8cd54951322fd503985f7c11c1cc1c (patch)
treea6d6a213575936bc31c53b59016837186d95b357
parent4c1bfef7c57993105fcad395f02e4b77cdad1b21 (diff)
downloadgcc-4784470a7e8cd54951322fd503985f7c11c1cc1c.zip
gcc-4784470a7e8cd54951322fd503985f7c11c1cc1c.tar.gz
gcc-4784470a7e8cd54951322fd503985f7c11c1cc1c.tar.bz2
re PR c++/63904 (ICE when accessing array member of constexpr struct)
2014-11-27 Kai Tietz <ktietz@redhat.com> PR c++/63904 * constexpr.c (cxx_eval_vec_init_1): Avoid type-overflow issue. From-SVN: r218123
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/constexpr.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9c64279..a59182b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-27 Kai Tietz <ktietz@redhat.com>
+
+ PR c++/63904
+ * constexpr.c (cxx_eval_vec_init_1): Avoid
+ type-overflow issue.
+
2014-11-26 Jason Merrill <jason@redhat.com>
Allow partial specialization of variable templates.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ef9ef70..f4aca4b 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2013,12 +2013,12 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
bool *non_constant_p, bool *overflow_p)
{
tree elttype = TREE_TYPE (atype);
- int max = tree_to_shwi (array_type_nelts (atype));
+ unsigned HOST_WIDE_INT max = tree_to_uhwi (array_type_nelts_top (atype));
verify_ctor_sanity (ctx, atype);
vec<constructor_elt, va_gc> **p = &CONSTRUCTOR_ELTS (ctx->ctor);
vec_alloc (*p, max + 1);
bool pre_init = false;
- int i;
+ unsigned HOST_WIDE_INT i;
/* For the default constructor, build up a call to the default
constructor of the element type. We only need to handle class types
@@ -2043,7 +2043,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
pre_init = true;
}
- for (i = 0; i <= max; ++i)
+ for (i = 0; i < max; ++i)
{
tree idx = build_int_cst (size_type_node, i);
tree eltinit;