This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch c++]: Fix PR/53904
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 26 Nov 2014 18:52:47 +0100
- Subject: Re: [patch c++]: Fix PR/53904
- Authentication-results: sourceware.org; auth=none
- References: <CAEwic4bN8mKygQk_30k8w-n3A-Q2181tQEzUFm3Y5W48ZWVHMg at mail dot gmail dot com> <5474CB66 dot 6030000 at redhat dot com>
Ok. Adjusted patch attached. Nevertheless we should use here
unsigned HWI instead of possible truncation to signed int. I admit
that it is unlikely to have more then 2^31 elements, but well ....
Ok for apply with adjusted ChangeLog?
Regards,
Kai
Index: constexpr.c
===================================================================
--- constexpr.c (Revision 218076)
+++ constexpr.c (Arbeitskopie)
@@ -2013,12 +2013,12 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tre
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, tre
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;