https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113612
Bug ID: 113612 Summary: ICE: SIGSEGV in get_template_info (pt.cc:378) or tree_check (tree.h:3611) with invalid -fpreprocessed Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zsojka at seznam dot cz Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Created attachment 57219 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57219&action=edit reduced testcase Compiler output: $ x86_64-pc-linux-gnu-gcc testcase.C -c $ x86_64-pc-linux-gnu-gcc -fpreprocessed testcase.C -wrapper valgrind,-q testcase.C:1:1: error: stray '#' in program 1 | #if defined0 | ^ testcase.C:6:1: error: stray '#' in program 6 | #endif | ^ testcase.C:1:2: error: expected unqualified-id before 'if' 1 | #if defined0 | ^~ ==1836== Invalid read of size 2 ==1836== at 0x10B82AE: get_template_info(tree_node const*) (pt.cc:378) ==1836== by 0x10D80F7: get_partial_spec_bindings(tree_node*, tree_node*, tree_node*) (pt.cc:25875) ==1836== by 0x10D890D: most_specialized_partial_spec(tree_node*, int, bool) (pt.cc:26190) ==1836== by 0x10D975F: instantiate_template(tree_node*, tree_node*, int) (pt.cc:22074) ==1836== by 0x113558A: finish_id_expression_1(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int) (semantics.cc:4392) ==1836== by 0x1135F66: finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int) (semantics.cc:4573) ==1836== by 0x107D2DA: cp_parser_primary_expression(cp_parser*, bool, bool, bool, bool, cp_id_kind*) (parser.cc:6300) ==1836== by 0x108A225: cp_parser_postfix_expression(cp_parser*, bool, bool, bool, bool, cp_id_kind*) (parser.cc:7924) ==1836== by 0x106805C: cp_parser_binary_expression(cp_parser*, bool, bool, bool, cp_parser_prec, cp_id_kind*) (parser.cc:10383) ==1836== by 0x1068D62: cp_parser_assignment_expression(cp_parser*, cp_id_kind*, bool, bool) (parser.cc:10727) ==1836== by 0x1069E85: cp_parser_constant_expression(cp_parser*, int, bool*, bool) (parser.cc:11017) ==1836== by 0x106AE16: cp_parser_initializer_clause(cp_parser*, bool*) (parser.cc:26126) ==1836== Address 0x53dce10 is in a rw- anonymous segment ==1836== ==1836== Invalid read of size 2 ==1836== at 0x10D80F8: tree_check (tree.h:3611) ==1836== by 0x10D80F8: get_partial_spec_bindings(tree_node*, tree_node*, tree_node*) (pt.cc:25875) ==1836== by 0x10D890D: most_specialized_partial_spec(tree_node*, int, bool) (pt.cc:26190) ==1836== by 0x10D975F: instantiate_template(tree_node*, tree_node*, int) (pt.cc:22074) ==1836== by 0x113558A: finish_id_expression_1(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int) (semantics.cc:4392) ==1836== by 0x1135F66: finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int) (semantics.cc:4573) ==1836== by 0x107D2DA: cp_parser_primary_expression(cp_parser*, bool, bool, bool, bool, cp_id_kind*) (parser.cc:6300) ==1836== by 0x108A225: cp_parser_postfix_expression(cp_parser*, bool, bool, bool, bool, cp_id_kind*) (parser.cc:7924) ==1836== by 0x106805C: cp_parser_binary_expression(cp_parser*, bool, bool, bool, cp_parser_prec, cp_id_kind*) (parser.cc:10383) ==1836== by 0x1068D62: cp_parser_assignment_expression(cp_parser*, cp_id_kind*, bool, bool) (parser.cc:10727) ==1836== by 0x1069E85: cp_parser_constant_expression(cp_parser*, int, bool*, bool) (parser.cc:11017) ==1836== by 0x106AE16: cp_parser_initializer_clause(cp_parser*, bool*) (parser.cc:26126) ==1836== by 0x106FA94: cp_parser_initializer(cp_parser*, bool*, bool*, bool) (parser.cc:26065) ==1836== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==1836== testcase.C:5:35: internal compiler error: Segmentation fault 5 | template <typename T> T *t<T *> = t<int> | ^~~~~~ 0x18044bf crash_signal /repo/gcc-trunk/gcc/toplev.cc:317 0x10d80f8 tree_check(tree_node*, char const*, int, char const*, tree_code) /repo/gcc-trunk/gcc/tree.h:3611 0x10d80f8 get_partial_spec_bindings /repo/gcc-trunk/gcc/cp/pt.cc:25875 0x10d890d most_specialized_partial_spec(tree_node*, int, bool) /repo/gcc-trunk/gcc/cp/pt.cc:26190 ... $ x86_64-pc-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-8419-20240125172014-gc6c2a1d79eb-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --disable-bootstrap --with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-r14-8419-20240125172014-gc6c2a1d79eb-checking-yes-rtl-df-extra-nobootstrap-amd64 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 14.0.1 20240125 (experimental) (GCC)