C++ PATCH for c++/85200, ICE with constexpr if in generic lambda
Jason Merrill
jason@redhat.com
Thu Apr 5 14:19:00 GMT 2018
On Wed, Apr 4, 2018 at 2:57 PM, Jason Merrill <jason@redhat.com> wrote:
> Since, during partial instantiation of a generic lambda, we don't
> substitute into the body of a constexpr if, we don't do lambda capture
> as part of substitution. But extract_locals_r is supposed to do it as
> part of remembering the substitution context to be used later.
>
> As it turns out, this was failing because walk_tree_1 expects the
> DECL_INITIAL of a local variable to be walked in the context of the
> BIND_EXPR, but we don't build BIND_EXPRs for compound-statements in a
> template. So in a template, let's walk the fields of a VAR_DECL from
> its DECL_EXPR.
...but I forgot to also check the original testcase, which was also
failing for a different reason: we were remembering the mapping from
fully general to partially instantiated even for the condition
variable of the constexpr if, which is wrong because we are discarding
that instantiation at this point, so using it in a later instantiation
breaks.
I also considered specifically removing the condition variable from
local_instantiations, but this more general approach seems safer.
Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 85200-2.diff
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180405/fe1c7bec/attachment.bin>
More information about the Gcc-patches
mailing list