https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119447
Bug ID: 119447 Summary: ICE Segmentation fault with incorrect template class declaration syntax and varadic parameter Product: gcc Version: unknown Status: UNCONFIRMED Keywords: ice-checking, 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: --- Simplified test input: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include <utility> template< typename T, typename U > struct template <typename> inclusive_scan{ }; template< std::size_t... Ns, std::size_t... Is > struct inclusive_scan< std::index_sequence< Ns... >, std::index_sequence< Is... > > { template< std::size_t I > using part = std::integral_constant< std::size_t, ( 0 + ... + ( ( Is <= I ) ? Ns : 0 ) ) >; using type = std::index_sequence< part< Is >::value... >; }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack Dump: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:4:17: error: 'template' must follow a nested-name-specifier before '<' token 4 | struct template <typename> inclusive_scan{ | ^ <source>:4:17: error: expected unqualified-id before '<' token <source>:8:8: error: 'inclusive_scan' is not a class template 8 | struct inclusive_scan< std::index_sequence< Ns... >, std::index_sequence< Is... > > | ^~~~~~~~~~~~~~ <source>:7:26: error: parameter pack 'Ns' must be at the end of the template parameter list 7 | template< std::size_t... Ns, std::size_t... Is > | ^~ <source>: In substitution of 'template<<declaration error>, long unsigned int ...Is> template<long unsigned int I> using inclusive_scan<<declaration error>, Is>::part = std::integral_constant<long unsigned int, (Is <= I ? Ns 0 + ... +0)> [with long unsigned int I = Is; <declaration error> = <expression error>; long unsigned int ...Is = {Is ...}]': <source>:13:48: required from here 13 | using type = std::index_sequence< part< Is >::value... >; | ^ <source>:13:48: internal compiler error: Segmentation fault 0x291f775 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x2936746 internal_error(char const*, ...) ???:0 0xb19080 pop_nested_class() ???:0 0xd467a3 instantiate_template(tree_node*, tree_node*, int) ???:0 0xd277b2 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int) ???:0 0xd71dbc finish_template_type(tree_node*, tree_node*, int) ???:0 0xcf2203 c_parse_file() ???:0 0xe545e9 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please see https://godbolt.org/z/4sKcdh7Ee