public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zsojka at seznam dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/113612] New: ICE: SIGSEGV in get_template_info (pt.cc:378) or tree_check (tree.h:3611) with invalid -fpreprocessed
Date: Fri, 26 Jan 2024 06:02:56 +0000	[thread overview]
Message-ID: <bug-113612-4@http.gcc.gnu.org/bugzilla/> (raw)

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)

             reply	other threads:[~2024-01-26  6:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  6:02 zsojka at seznam dot cz [this message]
2024-01-26  6:48 ` [Bug c++/113612] [13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-26  6:49 ` pinskia at gcc dot gnu.org
2024-01-26  8:37 ` rguenth at gcc dot gnu.org
2024-02-06 15:40 ` mpolacek at gcc dot gnu.org
2024-02-06 15:40 ` [Bug c++/113612] [13/14 Regression] ICE: SIGSEGV in get_template_info (pt.cc:378) or tree_check (tree.h:3611) mpolacek at gcc dot gnu.org
2024-02-06 15:46 ` mpolacek at gcc dot gnu.org
2024-02-13  2:00 ` jason at gcc dot gnu.org
2024-02-13 16:15 ` cvs-commit at gcc dot gnu.org
2024-02-13 16:16 ` cvs-commit at gcc dot gnu.org
2024-02-13 16:19 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113612-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).