https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120864
Bug ID: 120864 Summary: ICE Segmentation fault with deduced return type and concept Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- Starts to bailing out since gcc-12.1: https://godbolt.org/z/xf4xWPezv Test Input: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template < typename S > struct A { template<typename T> concept C = true; template < C T > static auto f () { return 0; } template<typename T> concept C = true; template < class U = decltype (f < S > ()) > int g () { return 0; } }; auto a = A < int > {}.g (); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack Dump: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:4:9: error: concept 'C' not in namespace scope [-Wtemplate-body] 4 | concept C = true; | ^ <source>:5:12: error: 'C' has not been declared [-Wtemplate-body] 5 | template < C T > static auto f () { return 0; } | ^ <source>:7:9: error: concept 'C' not in namespace scope [-Wtemplate-body] 7 | concept C = true; | ^ <source>: In instantiation of 'struct A<int>': <source>:11:21: required from here 11 | auto a = A < int > {}.g (); | ^ <source>:8:40: internal compiler error: Segmentation fault 8 | template < class U = decltype (f < S > ()) > int g () { return 0; } | ~~~~~~~~^~ 0x2843285 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x2865e26 internal_error(char const*, ...) ???:0 0xd4bccd tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0xd4c254 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0xd7a59c instantiate_class_template(tree_node*) ???:0 0xd96436 finish_compound_literal(tree_node*, tree_node*, int, fcl_t) ???:0 0xd16663 c_parse_file() ???:0 0xe7e3c9 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~