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++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
Date: Mon, 20 Feb 2023 17:45:34 +0000	[thread overview]
Message-ID: <bug-101073-4-Ium9n5A7jr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101073-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from CVS 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:b2287a4d9a640fdc2caef6a067830ea65044deb7

commit r13-6145-gb2287a4d9a640fdc2caef6a067830ea65044deb7
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Feb 8 19:13:18 2023 -0500

    c++: ICE with -fno-elide-constructors and trivial fn [PR101073]

    In constexpr-nsdmi3.C, with -fno-elide-constructors, we don't elide
    the Y::Y(const Y&) call used to initialize o.c.  So store_init_value
    -> cxx_constant_init must constexpr-evaluate the call to Y::Y(const Y&)
    in cxx_eval_call_expression.  It's a trivial function, so we do the
    "Shortcut trivial constructor/op=" code and rather than evaluating
    the function, we just create an assignment

      o.c = *(const struct Y &) (const struct Y *) &(&<PLACEHOLDER_EXPR struct
X>)->b

    which is a MODIFY_EXPR, so the preeval code in cxx_eval_store_expression
    clears .ctor and .object, therefore we can't replace the PLACEHOLDER_EXPR
    whereupon we crash at

          /* A placeholder without a referent.  We can get here when
             checking whether NSDMIs are noexcept, or in massage_init_elt;
             just say it's non-constant for now.  */
          gcc_assert (ctx->quiet);

    The PLACEHOLDER_EXPR can also be on the LHS as in constexpr-nsdmi10.C.
    I don't think we can do much here, but I noticed that the whole
    trivial_fn_p (fun) block is only entered when -fno-elide-constructors.
    This is true since GCC 9; it wasn't easy to bisect what changes made it
    so, but r240845 is probably one of them.  -fno-elide-constructors is an
    option for experiments only so it's not clear to me why we'd still want
    to shortcut trivial constructor/op=.  I propose to remove the code and
    add a checking assert to make sure we're not getting a trivial_fn_p
    unless -fno-elide-constructors.

            PR c++/101073

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_call_expression): Replace shortcutting
trivial
            constructor/op= with a checking assert.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-nsdmi3.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi10.C: New test.

  parent reply	other threads:[~2023-02-20 17:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 " gscfq@t-online.de
2021-06-15  7:53 ` [Bug c++/101073] " rguenth at gcc dot gnu.org
2021-10-02  7:45 ` pinskia at gcc dot gnu.org
2021-12-30 16:41 ` jakub at gcc dot gnu.org
2022-05-27  9:45 ` [Bug c++/101073] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-02-08 22:41 ` mpolacek at gcc dot gnu.org
2023-02-09 14:16 ` mpolacek at gcc dot gnu.org
2023-02-20 17:45 ` cvs-commit at gcc dot gnu.org [this message]
2023-02-20 17:51 ` 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-101073-4-Ium9n5A7jr@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).