https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120155
Bug ID: 120155 Summary: ICE when lambda return type is the decltype of statement expression Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: winmikedows at hotmail dot com Target Milestone: --- ```cpp void fun() { [](auto t) -> decltype( ({ int a = t; }) ) {}; } ``` ICEs all the way from GCC 11.1 to trunk. Interestingly, in published versions (11.1 to 15.1) the error message is ``` <source>: In function 'void fun()': <source>:5:21: internal compiler error: in dependent_type_p, at cp/pt.c:26813 5 | int a = t; | ^ 0x1780bf9 internal_error(char const*, ...) ???:0 0x677e40 fancy_abort(char const*, int, char const*) ???:0 0x7cc37c dependent_type_p(tree_node*) ???:0 0x6b50e5 is_rvalue_constant_expression(tree_node*) ???:0 0x7c0cab c_parse_file() ???:0 0x892aa2 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ``` And in trunk the error message is ``` <source>: In function 'void fun()': <source>:5:17: internal compiler error: tree check: expected tree that contains 'decl with visibility' structure, have 'parm_decl' in start_decl, at cp/decl.cc:6037 5 | int a = t; | ^ 0x293cc75 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x2956c96 internal_error(char const*, ...) ???:0 0x9dff77 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*) ???:0 0xcfa3d3 c_parse_file() ???:0 0xe5ce99 c_common_parse_file() ???:0 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. ``` Before 10.5, this just throws an error "non-function 'a' declared as implicit template". Trunk also ICEs when replacing `int a = t;` with `int a = 1;`, but all published versions do not. Runnable example: https://godbolt.org/z/9ncd7xYWc