Reduced from ccache package: $ cat LocalStorage.ii template <int __v> struct integral_constant { static constexpr int value = __v; }; template <bool, typename _Tp> using __enable_if_t = _Tp; template <typename> using __void_t = void; template <typename _Tp> _Tp __declval(long); template <typename _Tp> auto declval() -> decltype(__declval<_Tp>(0)); template <typename> struct __result_of_success; template <bool, bool, typename...> struct __result_of_impl; template <typename _Fn, typename... _Args> __result_of_success<decltype(declval<_Fn>()(declval<_Args>...))> _S_test; template <typename _Functor, typename... _ArgTypes> struct __result_of_impl<false, false, _Functor, _ArgTypes...> { typedef decltype(_S_test<_Functor, _ArgTypes...>) type; }; template <typename _Functor, typename... _ArgTypes> struct __invoke_result : __result_of_impl<integral_constant<false>::value, integral_constant<false>::value, _Functor, _ArgTypes...> {}; template <typename, typename, typename = void> struct __is_invocable_impl; template <typename _Result, typename _Ret> struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> : integral_constant<true> {}; template <typename> class function; template <typename _Cond, typename _Tp = void> using _Requires = __enable_if_t<_Cond::value, _Tp>; template <typename _Res, typename... _ArgTypes> struct function<_Res(_ArgTypes...)> { template <typename _Func, typename _DFunc = _Func, typename _Res2 = __invoke_result<_DFunc, _ArgTypes...>> struct _Callable : __is_invocable_impl<_Res2, _Res> {}; template <typename _Functor, typename = _Requires<_Callable<_Functor>>> function(_Functor) {} }; void for_each_cache_subdir(function<void(char, function<void>)>) { for_each_cache_subdir([](auto, auto) { [](auto) { ({ struct __attribute__FMT_COMPILE_STRING {}; }); }; }); } $ g++ LocalStorage.ii -c LocalStorage.ii: In instantiation of ‘for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)> [with auto:1 = char (*)(); auto:2 = function<void> (*)()]’: LocalStorage.ii:11:44: required from ‘struct __result_of_impl<false, false, for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> >’ LocalStorage.ii:31:10: recursively required by substitution of ‘template<class _Result, class _Ret> struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type> > [with _Result = __invoke_result<for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> >; _Ret = void]’ LocalStorage.ii:31:10: required from ‘struct function<void(char, function<void>)>::_Callable<for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, __invoke_result<for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> > >’ LocalStorage.ii:26:7: required by substitution of ‘template<class _Cond, class _Tp> using _Requires = __enable_if_t<_Cond::value, _Tp> [with _Cond = function<void(char, function<void>)>::_Callable<for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, __invoke_result<for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> > >; _Tp = void]’ LocalStorage.ii:32:32: required by substitution of ‘template<class _Functor, class> function<void(char, function<void>)>::function(_Functor) [with _Functor = for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1, auto:2)>; <template-parameter-1-2> = <missing>]’ LocalStorage.ii:36:24: required from here LocalStorage.ii:38:7: internal compiler error: Segmentation fault 38 | ({ | ^ 0x11978cf crash_signal /home/marxin/Programming/gcc/gcc/toplev.cc:314 0x7ffff78b1edf ??? /usr/src/debug/glibc-2.37/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0xb19347 tree_check(tree_node*, char const*, int, char const*, tree_code) /home/marxin/Programming/gcc/gcc/tree.h:3539 0xb19347 find_parameter_packs_r /home/marxin/Programming/gcc/gcc/cp/pt.cc:4073 0x14873cd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/marxin/Programming/gcc/gcc/tree.cc:11327 0x1487a40 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/marxin/Programming/gcc/gcc/tree.cc:11442 0xb1b105 check_for_bare_parameter_packs(tree_node*, unsigned int) /home/marxin/Programming/gcc/gcc/cp/pt.cc:4283 0xb7b5a5 finish_expr_stmt(tree_node*) /home/marxin/Programming/gcc/gcc/cp/semantics.cc:904 0xb3c3d2 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:18856 0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204 0xb66e68 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:18810 0xb66e68 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:20203 0xb2f796 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:21715 0xb3977f tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:19872 0xb3ae47 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:18852 0xb3a201 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:18824 0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204 0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204 0xb46215 tsubst_expr(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.cc:18810 0xb46215 instantiate_body /home/marxin/Programming/gcc/gcc/cp/pt.cc:26815 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
Reduced almost all the way: ``` void g() { [](auto) { []<int>() { ({ struct __attribute__FMT_COMPILE_STRING {}; }); }; }(1); } ```
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:4872e46e080c6695dfe1f9dc9db26b4703bc348c commit r13-6824-g4872e46e080c6695dfe1f9dc9db26b4703bc348c Author: Jason Merrill <jason@redhat.com> Date: Wed Mar 22 16:11:47 2023 -0400 c++: local class in nested generic lambda [PR109241] In this testcase, the tree walk to look for bare parameter packs was confused by finding a type with no TREE_BINFO. But it should be fine that it's unset; we already checked for unexpanded packs at parse time. I also tried doing the partial instantiation of the local class, which is probably the long-term direction we want to go, but for stage 4 let's go with this safer change. PR c++/109241 gcc/cp/ChangeLog: * pt.cc (find_parameter_packs_r): Handle null TREE_BINFO. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/lambda-generic-local-class2.C: New test.
I guess it's fixed now.
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:d60cbbfaa9a3ad3bd1f613be95add939c16fc9a1 commit r14-278-gd60cbbfaa9a3ad3bd1f613be95add939c16fc9a1 Author: Jason Merrill <jason@redhat.com> Date: Wed Mar 22 16:11:47 2023 -0400 c++: local class in nested generic lambda [PR109241] The earlier fix for PR109241 avoided the crash by handling a type with no TREE_BINFO. But we want to move toward doing the partial substitution of classes in generic lambdas, so let's take a step in that direction. PR c++/109241 gcc/cp/ChangeLog: * pt.cc (instantiate_class_template): Do partially instantiate. (tsubst_expr): Do call complete_type for partial instantiations.
In GCC 12 this test still ICEs: template<class T> void foo(T) { [](auto){ [] { struct X {}; }; }; } template void foo(int);
*** Bug 109803 has been marked as a duplicate of this bug. ***
*** Bug 109850 has been marked as a duplicate of this bug. ***
(In reply to Marek Polacek from comment #5) > In GCC 12 this test still ICEs: > > template<class T> > void foo(T) { > [](auto){ > [] { > struct X {}; > }; > }; > } > > template void foo(int); How so? I can't reproduce. Likewise for PR109850. Is trunk actually fixed? Please update known-to-work.
The releases/gcc-12 branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:396a4e76afec30d2461638f569cae18955eb4ad2 commit r12-9539-g396a4e76afec30d2461638f569cae18955eb4ad2 Author: Jason Merrill <jason@redhat.com> Date: Wed Mar 22 16:11:47 2023 -0400 c++: local class in nested generic lambda [PR109241] In this testcase, the tree walk to look for bare parameter packs was confused by finding a type with no TREE_BINFO. But it should be fine that it's unset; we already checked for unexpanded packs at parse time. I also tried doing the partial instantiation of the local class, which is probably the long-term direction we want to go, but for stage 4 let's go with this safer change. PR c++/109241 gcc/cp/ChangeLog: * pt.cc (find_parameter_packs_r): Handle null TREE_BINFO. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/lambda-generic-local-class2.C: New test.
*** Bug 109872 has been marked as a duplicate of this bug. ***
*** Bug 110306 has been marked as a duplicate of this bug. ***
Closing again.
*** Bug 106398 has been marked as a duplicate of this bug. ***
*** Bug 115195 has been marked as a duplicate of this bug. ***