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++/110382] [13/14 Regression] internal compiler error: in verify_ctor_sanity
Date: Tue, 25 Jul 2023 18:06:08 +0000	[thread overview]
Message-ID: <bug-110382-4-EbQvmXzpoi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110382-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 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:6e424febfbcb27c21a7fe3a137e614765f9cf9d2

commit r14-2762-g6e424febfbcb27c21a7fe3a137e614765f9cf9d2
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Jul 21 17:48:37 2023 -0400

    c++: fix ICE with constexpr ARRAY_REF [PR110382]

    This code in cxx_eval_array_reference has been hard to get right.
    In r12-2304 I added some code; in r13-5693 I removed some of it.

    Here the problematic line is "S s = arr[0];" which causes a crash
    on the assert in verify_ctor_sanity:

      gcc_assert (!ctx->object || !DECL_P (ctx->object)
                  || ctx->global->get_value (ctx->object) == ctx->ctor);

    ctx->object is the VAR_DECL 's', which is correct here.  The second
    line points to the problem: we replaced ctx->ctor in
    cxx_eval_array_reference:

      new_ctx.ctor = build_constructor (elem_type, NULL); // #1

    which I think we shouldn't have; the CONSTRUCTOR we created in
    cxx_eval_constant_expression/DECL_EXPR

      new_ctx.ctor = build_constructor (TREE_TYPE (r), NULL);

    had the right type.

    We still need #1 though.  E.g., in constexpr-96241.C, we never
    set ctx.ctor/object before calling cxx_eval_array_reference, so
    we have to build a CONSTRUCTOR there.  And in constexpr-101371-2.C
    we have a ctx.ctor, but it has the wrong type, so we need a new one.

    We can fix the problem by always clearing the object, and, as an
    optimization, only create/free a new ctor when actually needed.

            PR c++/110382

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_array_reference): Create a new constructor
            only when we don't already have a matching one.  Clear the object
            when the type is non-scalar.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/constexpr-110382.C: New test.

  parent reply	other threads:[~2023-07-25 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 22:21 [Bug c++/110382] New: " mpolacek at gcc dot gnu.org
2023-06-23 22:21 ` [Bug c++/110382] " mpolacek at gcc dot gnu.org
2023-07-21 17:31 ` mpolacek at gcc dot gnu.org
2023-07-21 18:29 ` mpolacek at gcc dot gnu.org
2023-07-25 18:06 ` cvs-commit at gcc dot gnu.org [this message]
2023-07-25 18:07 ` [Bug c++/110382] [13 " mpolacek at gcc dot gnu.org
2023-07-27  9:27 ` rguenth at gcc dot gnu.org
2024-05-21  9:16 ` jakub 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-110382-4-EbQvmXzpoi@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).