public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99831] [10/11 Regression] ICE: in reshape_init, at cp/decl.c:6720
Date: Thu, 01 Apr 2021 21:35:05 +0000	[thread overview]
Message-ID: <bug-99831-4-j30SOWCirY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99831-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99831

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:6a60ffc297b9d4903543a25538e62e7fb39420a9

commit r11-7954-g6a60ffc297b9d4903543a25538e62e7fb39420a9
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Apr 1 10:42:43 2021 -0400

    c++: GC collects live data when synthesizing operator== [PR99831]

    Here we crash in reshape_init because we're accessing ggc_freed
    & poisoned data: since r277865 in defaulted_late_check we call
    synthesize_method here:

      if (kind == sfk_comparison)
        {
          /* If the function was declared constexpr, check that the definition
             qualifies.  Otherwise we can define the function lazily.  */
          if (DECL_DECLARED_CONSTEXPR_P (fn) && !DECL_INITIAL (fn))
            synthesize_method (fn);
          return;
        }

    which in this test triggers when we're processing the string<"a">{} in
    the static_assert.  First, we create a CONSTRUCTOR for the "{}" in
    cp_parser_functional_cast, then we call finish_compound_literal which
    calls complete_type and that results in garbage collection, which then
    frees the CONSTRUCTOR {} we created when parsing the braced-list in
    string<"a">{} -- at this point, it's not referenced by anything.
    (That's not the case for 'type' in finish_compound_literal: the symbol
    table contains a node for operator==, so ggc_mark_roots goes and marks
    the fn decl, its type, its arguments etc., as used, so we don't collect
    it.)

    We could just bump function_depth around the new call to synthesize_method
    to prevent GC.

    gcc/cp/ChangeLog:

            PR c++/99831
            * method.c (defaulted_late_check): ++ and -- function_depth around
            the call to synthesize_method.
            * pt.c: Remove the saved_trees global.

    gcc/testsuite/ChangeLog:

            PR c++/99831
            * g++.dg/other/gc6.C: New test.

  parent reply	other threads:[~2021-04-01 21:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 14:27 [Bug c++/99831] New: " hewillk at gmail dot com
2021-03-30 14:34 ` [Bug c++/99831] " hewillk at gmail dot com
2021-03-30 14:41 ` mpolacek at gcc dot gnu.org
2021-03-30 15:04 ` mpolacek at gcc dot gnu.org
2021-03-30 17:43 ` hewillk at gmail dot com
2021-03-30 19:14 ` mpolacek at gcc dot gnu.org
2021-03-30 19:34 ` mpolacek at gcc dot gnu.org
2021-03-30 19:46 ` mpolacek at gcc dot gnu.org
2021-03-30 19:51 ` mpolacek at gcc dot gnu.org
2021-03-31  1:04 ` mpolacek at gcc dot gnu.org
2021-03-31  7:54 ` [Bug c++/99831] [10/11 Regression] " rguenth at gcc dot gnu.org
2021-04-01 18:18 ` mpolacek at gcc dot gnu.org
2021-04-01 21:35 ` cvs-commit at gcc dot gnu.org [this message]
2021-04-01 21:37 ` [Bug c++/99831] [10 " mpolacek at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-04-09 22:45 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:46 ` mpolacek 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-99831-4-j30SOWCirY@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).