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++/97966] [10 Regression] maybe_instantiate_noexcept
Date: Fri, 09 Apr 2021 22:32:40 +0000	[thread overview]
Message-ID: <bug-97966-4-AN1w1clxuK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97966-4@http.gcc.gnu.org/bugzilla/>

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

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

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

commit r10-9683-g6f45079013256ed730c92bf35af4e6394cb5a2c0
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Apr 9 18:31:12 2021 -0400

    c++: ICE with delayed noexcept and attribute used [PR97966]

    Another ICE with delayed noexcept parsing, but a bit gnarlier.

    A function definition marked with __attribute__((used)) ought to be
    emitted even when it is not referenced in the TU.  For a member function
    template marked with __attribute__((used)) this means that it will
    be instantiated: in instantiate_class_template_1 we have

    11971               /* Instantiate members marked with attribute used.  */
    11972               if (r != error_mark_node && DECL_PRESERVE_P (r))
    11973                 mark_used (r);

    It is not so surprising that this doesn't work well with delayed
    noexcept parsing: when we're processing the function template we delay
    the parsing, so the member "foo" is found, but then when we're
    instantiating it, "foo" hasn't yet been seen, which creates a
    discrepancy and a crash ensues.  "foo" hasn't yet been seen because
    instantiate_class_template_1 just loops over the class members and
    instantiates right away.

    To make it work, this patch uses a vector to keep track of members
    marked with attribute used and uses it to instantiate such members
    only after we're done with the class; in particular, after we have
    called finish_member_declaration for each member.  And we ought to
    be verifying that we did emit such members, so I've added a bunch
    of dg-finals.

    gcc/cp/ChangeLog:

            PR c++/97966
            * pt.c (instantiate_class_template_1): Instantiate members
            marked with attribute used only after we're done instantiating
            the class.

    gcc/testsuite/ChangeLog:

            PR c++/97966
            * g++.dg/cpp0x/noexcept63.C: New test.

  parent reply	other threads:[~2021-04-09 22:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 11:53 [Bug c++/97966] New: maybe_instantiate_noexcept jonathan.k at qspark dot co
2020-11-24 11:56 ` [Bug c++/97966] maybe_instantiate_noexcept jonathan.k at qspark dot co
2020-11-30 18:18 ` [Bug c++/97966] [10/11 Regression] maybe_instantiate_noexcept mpolacek at gcc dot gnu.org
2020-11-30 18:56 ` mpolacek at gcc dot gnu.org
2021-01-14  9:43 ` rguenth at gcc dot gnu.org
2021-01-22  1:09 ` cvs-commit at gcc dot gnu.org
2021-01-22  1:10 ` [Bug c++/97966] [10 " mpolacek at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-04-09 22:32 ` cvs-commit at gcc dot gnu.org [this message]
2021-04-09 22:33 ` mpolacek at gcc dot gnu.org
2021-04-11 12:44 ` ebotcazou at gcc dot gnu.org
2021-04-11 16:58 ` mpolacek at gcc dot gnu.org
2021-04-11 22:58 ` cvs-commit at gcc dot gnu.org
2021-04-11 22:58 ` mpolacek at gcc dot gnu.org
2021-04-13 10:47 ` ebotcazou 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-97966-4-AN1w1clxuK@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).