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++/114854] [11/12/13/14/15 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822
Date: Wed, 15 May 2024 17:28:12 +0000	[thread overview]
Message-ID: <bug-114854-4-Sbr9iyVYRl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114854-4@http.gcc.gnu.org/bugzilla/>

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

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

https://gcc.gnu.org/g:1a05332bbac98a4c002bef3fb45a3ad9d56b3a71

commit r15-523-g1a05332bbac98a4c002bef3fb45a3ad9d56b3a71
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed May 8 15:43:58 2024 -0400

    c++: ICE with reference NSDMI [PR114854]

    Here we crash on a cp_gimplify_expr/TARGET_EXPR assert:

          /* A TARGET_EXPR that expresses direct-initialization should have
been
             elided by cp_gimplify_init_expr.  */
          gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (*expr_p));

    the TARGET_EXPR in question is created for the NSDMI in:

      class Vector { int m_size; };
      struct S {
        const Vector &vec{};
      };

    where we first need to create a Vector{} temporary, and then bind the
    vec reference to it.  The temporary is represented by a TARGET_EXPR
    and it cannot be elided.  When we create an object of type S, we get

      D.2848 = {.vec=(const struct Vector &) &TARGET_EXPR <D.2840,
{.m_size=0}>}

    where the TARGET_EXPR is no longer direct-initializing anything.

    Fixed by not setting TARGET_EXPR_DIRECT_INIT_P in
convert_like_internal/ck_user.

            PR c++/114854

    gcc/cp/ChangeLog:

            * call.cc (convert_like_internal) <case ck_user>: Don't set
            TARGET_EXPR_DIRECT_INIT_P.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/nsdmi-aggr22.C: New test.

      parent reply	other threads:[~2024-05-15 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
2024-04-25 14:23 ` [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822 ppalka at gcc dot gnu.org
2024-04-25 15:45 ` mpolacek at gcc dot gnu.org
2024-05-07 21:31 ` [Bug c++/114854] [11/12/13/14/15 " mpolacek at gcc dot gnu.org
2024-05-15 17:28 ` cvs-commit at gcc dot gnu.org [this message]

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-114854-4-Sbr9iyVYRl@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).