This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to fix rejects-valid with constexpr ctor in C++17 (PR c++/83692)
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Thu, 25 Jan 2018 23:08:18 +0100
- Subject: Re: C++ PATCH to fix rejects-valid with constexpr ctor in C++17 (PR c++/83692)
- Authentication-results: sourceware.org; auth=none
- References: <20180125211639.GA2620@redhat.com>
On Thu, Jan 25, 2018 at 10:16:39PM +0100, Marek Polacek wrote:
> This is a similar problem to 83116: we'd cached a constexpr call, but after a
> store the result had become invalid, yet we used the wrong result again when
> encountering the same call later. This resulted in evaluating a THROW_EXPR
> which doesn't work. Details in
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83692#c5
>
> The fix for 83116 didn't work here, because when evaluating the body of the
> ctor via store_init_value -> cxx_constant_value we are in STRICT, so we do
> cache.
>
> It seems that we may no longer rely on the constexpr call table when we
> do cxx_eval_store_expression, because that just rewrites *valp, i.e. the
> value of an object. Might be too big a hammer again, but I couldn't think
> of how I could guard the caching of a constexpr call.
>
> This doesn't manifest in C++14 because build_special_member_call in C++17 is
> more aggressive with copy elisions (as required by P0135 which changed how we
> view prvalues). In C++14 build_special_member_call produces a CALL_EXPR, so
> expand_default_init calls maybe_constant_init, for which STRICT is false, so
> we avoid caching as per 83116.
...so the testcase should actually test c++17. Consider that fixed.
Marek