On 1/11/21 4:40 PM, Jason Merrill wrote: > On 1/7/21 4:06 PM, Patrick Palka wrote: >> This is essentially a followup to r11-3714 -- we ICEing from another >> "unguarded" call to build_concept_check, this time in do_auto_deduction, >> due to the presence of templated trees when !processing_template_decl. >> >> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >> trunk and perhaps the 10 branch? >> >> gcc/cp/ChangeLog: >> >>     PR c++/98346 >>     * pt.c (do_auto_deduction): Temporarily increment >>     processing_template_decl before calling build_concept_check. >> >> gcc/testsuite/ChangeLog: >> >>     PR c++/98346 >>     * g++.dg/cpp2a/concepts-placeholder3.C: New test. >> --- >>   gcc/cp/pt.c                                       |  2 ++ >>   .../g++.dg/cpp2a/concepts-placeholder3.C          | 15 +++++++++++++++ >>   2 files changed, 17 insertions(+) >>   create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C >> >> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c >> index beabcc4b027..111a694e0c5 100644 >> --- a/gcc/cp/pt.c >> +++ b/gcc/cp/pt.c >> @@ -29464,7 +29464,9 @@ do_auto_deduction (tree type, tree init, tree >> auto_node, >>             cargs = targs; >>       /* Rebuild the check using the deduced arguments.  */ >> +    ++processing_template_decl; >>       check = build_concept_check (cdecl, cargs, tf_none); >> +    --processing_template_decl; > > This shouldn't be necessary; if processing_template_decl is 0, we should > have non-dependent args. > > I think your patch only works for this testcase because the concept is > trivial and doesn't actually try to to do anything with the arguments. > > Handling of PLACEHOLDER_TYPE_CONSTRAINTS is overly complex, partly > because the 'auto' is represented as an argument in its own constraints. > > A constrained auto variable declaration has the same problem. Appling the patch below turns up similar problems in a couple of existing testcases.