This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to fix wrong-code with constexpr call table cache (PR c++/83116)
- From: Jason Merrill <jason at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Nathan Sidwell <nathan at acm dot org>
- Date: Mon, 18 Dec 2017 13:07:18 -0500
- Subject: Re: C++ PATCH to fix wrong-code with constexpr call table cache (PR c++/83116)
- Authentication-results: sourceware.org; auth=none
- References: <20171218150923.GK2605@redhat.com>
On Mon, Dec 18, 2017 at 10:09 AM, Marek Polacek <polacek@redhat.com> wrote:
> Here the problem was that cxx_eval_call_expression can cache the result of a
> constexpr call in constexpr_call_table, but we have to be careful, after
> store_init_value the result might be invalid. So I believe we also have to
> clear the constexpr call table. I've lumped it together with clearing
> cv_cache.
Hmm, that seems like a big hammer; the problem isn't that
store_init_value makes the result invalid, it's that the result
calculated during store_init_value (when we can treat the object as
constant) isn't relevant later (when the object is no longer
constant). So we want to avoid caching when we're called for the
initial value. Maybe by changing
if (depth_ok && !non_constant_args)
to
if (depth_ok && !non_constant_args && ctx->strict)
? Does that work?