https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119998
Bug ID: 119998 Summary: ICE (segfault) on missing constraint in redeclaration. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: luc.grosheintz at gmail dot com Target Milestone: --- Created attachment 61235 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61235&action=edit Preprocessed sources and compilation command. The reproducer has also been setup on Godbolt: https://godbolt.org/z/o8Y6rGWfq The following invalid code causes a segfault in GCC trunk (e.g. commit `1c0cbc1b300e08df5ebfce00a7195890d78f2064`): ``` struct A { template <typename T> struct B; }; template <typename T> requires true struct A::B { template<typename U> B(U u); }; template<typename T> template<typename U> A::B<T>::B(U u) {} ``` (the requires clause differs in the redeclaration.) The error message is: ``` Segmentation fault 16 | A::B<T>::B(U u) {} | ^ 0x29720df internal_error(char const*, ...) ../../gcc-bug/gcc/diagnostic-global-context.cc:517 0x145866f crash_signal ../../gcc-bug/gcc/toplev.cc:321 0xbd4fed cp_printer ../../gcc-bug/gcc/cp/error.cc:4689 0x2995638 format_phase_2 ../../gcc-bug/gcc/pretty-print.cc:2157 0x2995638 pretty_printer::format(text_info&) ../../gcc-bug/gcc/pretty-print.cc:1710 0x295c238 pp_format(pretty_printer*, text_info*) ../../gcc-bug/gcc/pretty-print.h:594 0x295c238 diagnostic_context::report_diagnostic(diagnostic_info*) ../../gcc-bug/gcc/diagnostic.cc:1504 0x295c665 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ../../gcc-bug/gcc/diagnostic.cc:1640 0x29718af error(char const*, ...) ../../gcc-bug/gcc/diagnostic-global-context.cc:397 0xd3c9cd push_template_decl(tree_node*, bool) ../../gcc-bug/gcc/cp/pt.cc:6250 0xb88aab start_preparsed_function(tree_node*, tree_node*, int) ../../gcc-bug/gcc/cp/decl.cc:18500 0xb9f946 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*) ../../gcc-bug/gcc/cp/decl.cc:18837 0xccbfd7 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc-bug/gcc/cp/parser.cc:33569 0xccbfd7 cp_parser_init_declarator ../../gcc-bug/gcc/cp/parser.cc:24051 0xcd40e3 cp_parser_single_declaration ../../gcc-bug/gcc/cp/parser.cc:34112 0xcd433f cp_parser_template_declaration_after_parameters ../../gcc-bug/gcc/cp/parser.cc:33766 0xcd433f cp_parser_explicit_template_declaration ../../gcc-bug/gcc/cp/parser.cc:33940 0xcd4767 cp_parser_template_declaration_after_export ../../gcc-bug/gcc/cp/parser.cc:33959 0xcd4767 cp_parser_template_declaration_after_parameters ../../gcc-bug/gcc/cp/parser.cc:33754 0xcd4767 cp_parser_explicit_template_declaration ../../gcc-bug/gcc/cp/parser.cc:33940 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Preprocessed source stored into /tmp/ccLr1ffQ.out file, please attach this to your bugreport. ``` The bug looks similar to PR118060 but the reproducer in that bug report doesn't fail anymore on GCC trunk. On Godbolt GCC 15.1 prints the following error message: ``` <source>:16: confused by earlier errors, bailing out ```