https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91705

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Candidate fix:

--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4162,7 +4162,6 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx,
tree t,
   tree type = TREE_TYPE (t);
   tree op = TREE_OPERAND (t, 0);
   tree offset = TREE_OPERAND (t, 1);
-  gcc_assert (TREE_CONSTANT (offset));

   /* The operand as an lvalue.  */
   op = cxx_eval_constant_expression (ctx, op, true,
@@ -4172,6 +4171,11 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx,
tree t,
   tree val
     = cxx_eval_constant_expression (ctx, op, false,
                    non_constant_p, overflow_p);
+
+  offset = cxx_eval_constant_expression (ctx, offset, false,
+                    non_constant_p, overflow_p);
+  VERIFY_CONSTANT (offset);
+
   /* Don't VERIFY_CONSTANT if this might be dealing with a pointer to
      a local array in a constexpr function.  */
   bool ptr = INDIRECT_TYPE_P (TREE_TYPE (val));

Reply via email to