diff options
author | Alexandre Oliva <oliva@adacore.com> | 2022-12-29 14:32:59 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2022-12-29 14:39:47 -0300 |
commit | 6ec8079e0b7dc7c44a7001ffb20ca038362191d5 (patch) | |
tree | 836013364cf807a42d7f33a5ad7857ea615a8628 | |
parent | 06be65894f7f18058496aa0e55bb7ec5613cb2a3 (diff) | |
download | gcc-6ec8079e0b7dc7c44a7001ffb20ca038362191d5.zip gcc-6ec8079e0b7dc7c44a7001ffb20ca038362191d5.tar.gz gcc-6ec8079e0b7dc7c44a7001ffb20ca038362191d5.tar.bz2 |
[C++] constexpr: request insert iff depth is ok
cxx_eval_call_expression requests an INSERT even in cases when it
would later decide not to insert. This could break double-hashing
chains. Arrange for it to use NO_INSERT when the insertion would not
be completed.
for gcc/cp/ChangeLog
* constexpr.cc (cxx_eval_call_expression): Do not request an
INSERT that would not be completed.
-rw-r--r-- | gcc/cp/constexpr.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 414af7a..a65dbdc 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. */ |