From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id E90D1385B500; Fri, 23 Dec 2022 07:31:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E90D1385B500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671780707; bh=qfKhgphtBneAHWAJtpSrwXAa2Y3r8yeC+HnxzLTJhdM=; h=From:To:Subject:Date:From; b=wAINwhisZA7axBKRpKejh/2/fpWcQpiVawDNGt8YGXs2bXxye6/eqG8sJ1u5oa8Ay LiIcqYJD+q8i+iqeYe4L7vmLpXhyRkYA42g2wD77W6+WbixxlMGY7y19WFrY489egC wLk32P23M33OrssArVafvxXJWqsXm9CkMCFQN4ss= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] [C++] constexpr: request insert iff depth is ok X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 2b21b5586e4cd129b8a1b11d97333f054d01b522 X-Git-Newrev: fd657c67978b83cc4bed5425cdc7fd6b187052de Message-Id: <20221223073147.E90D1385B500@sourceware.org> Date: Fri, 23 Dec 2022 07:31:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fd657c67978b83cc4bed5425cdc7fd6b187052de commit fd657c67978b83cc4bed5425cdc7fd6b187052de Author: Alexandre Oliva Date: Fri Dec 23 02:25:54 2022 -0300 [C++] constexpr: request insert iff depth is ok Diff: --- gcc/cp/constexpr.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index d99c49bdbe2..6d20ffa2cde 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -3000,13 +3000,15 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, /* If we have seen this call before, we are done. */ maybe_initialize_constexpr_call_table (); + bool insert = depth_ok < constexpr_cache_depth; constexpr_call **slot - = constexpr_call_table->find_slot (&new_call, INSERT); - entry = *slot; + = constexpr_call_table->find_slot (&new_call, + insert ? INSERT : NO_INSERT); + entry = slot ? *slot : NULL; if (entry == NULL) { /* Only cache up to constexpr_cache_depth to limit memory use. */ - if (depth_ok < constexpr_cache_depth) + if (insert) { /* We need to keep a pointer to the entry, not just the slot, as the slot can move during evaluation of the body. */