Here tsubst_pack_expansion assumes that we should have arguments for all packs if we're not in a template, but we might not if there's an auto pack.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 445cd04fd16f17dd499f2f7eb2ac8a723e9071a4 Author: Jason Merrill <ja...@redhat.com> Date: Wed Apr 4 14:53:08 2018 -0400 PR c++/85006 - -fconcepts ICE with A<auto...> return type * pt.c (tsubst_pack_expansion): Allow unsubstituted auto pack. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 80670a4826b..dbbc7666721 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11860,7 +11860,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, /* We can't substitute for this parameter pack. We use a flag as well as the missing_level counter because function parameter packs don't have a level. */ - gcc_assert (processing_template_decl); + gcc_assert (processing_template_decl || is_auto (parm_pack)); unsubstituted_packs = true; } } diff --git a/gcc/testsuite/g++.dg/concepts/auto4.C b/gcc/testsuite/g++.dg/concepts/auto4.C new file mode 100644 index 00000000000..e80341ec038 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/auto4.C @@ -0,0 +1,11 @@ +// PR c++/85006 +// { dg-additional-options "-std=c++17 -fconcepts" } + +template<typename... Ts> struct A {}; + +template<typename... Us> A<auto...> foo() { return A{}; } + +void bar() +{ + foo(); +}