https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Bug ID: 114303 Summary: ICE with constexpr if and static_assert accessing captures across nested generic lambdas Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: benbarsdell at gmail dot com Target Milestone: --- Similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105788 but the backtrace is different. https://godbolt.org/z/xMPeTo633 Repros with the following versions on Godbolt: 14.0.1 ICE (gcc trunk on Godbolt) 13.2: ICE 13.1: ICE 12.3: ICE 12.2: OK 12.1: OK 11.4: ICE 11.3: OK #include <type_traits> int main() { auto foo = [](auto level1) { return [&](auto ) { return [&](auto level3) { if constexpr (decltype(level3)::value) { static_assert(decltype(level1)::value, ""); } return 0; }(std::integral_constant<int, 1>()); }(0); }(std::integral_constant<int, 1>()); } <source>:8:17: internal compiler error: trying to capture 'level1' in instantiation of generic lambda 8 | if constexpr (decltype(level3)::value) { | ^~ 0x265eabc internal_error(char const*, ...) ???:0 0xb86956 add_capture(tree_node*, tree_node*, tree_node*, bool, bool, unsigned int*) ???:0 0xb869d9 add_default_capture(tree_node*, tree_node*, tree_node*) ???:0 0x16c682c 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*> >*)) ???:0 0x16c68a9 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*> >*)) ???:0 0xc75f26 build_extra_args(tree_node*, tree_node*, int) ???:0 0xcab766 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*) ???:0 0xc919b3 instantiate_decl(tree_node*, bool, bool) ???:0 0xb54725 maybe_instantiate_decl(tree_node*) ???:0 ...