From 95e3030cfa307191f87da77bb98b101f2ed88bec Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 27 Jan 2016 14:26:38 +0000 Subject: re PR c++/69496 ([C++ 14] ICE on VLA in constexpr function) PR c++/69496 * constexpr.c (cxx_eval_array_reference): Evaluate the number of elements of the array. * g++.dg/ext/constexpr-vla1.C: New test. From-SVN: r232875 --- gcc/cp/constexpr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/cp/constexpr.c') diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index bbb8ccf..fd80000 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1846,7 +1846,12 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t, if (!found) { - if (tree_int_cst_lt (index, array_type_nelts_top (TREE_TYPE (ary)))) + tree nelts = array_type_nelts_top (TREE_TYPE (ary)); + /* For VLAs, the number of elements won't be an integer constant. */ + nelts = cxx_eval_constant_expression (ctx, nelts, false, non_constant_p, + overflow_p); + VERIFY_CONSTANT (nelts); + if (tree_int_cst_lt (index, nelts)) { if (TREE_CODE (ary) == CONSTRUCTOR && CONSTRUCTOR_NO_IMPLICIT_ZERO (ary)) -- cgit v1.1