public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/113083] [14 Regression][arm] ICE in fold_convert_loc, at fold-const.cc:2602 since r14-5979-g99d114c15523e0
Date: Thu, 22 Feb 2024 21:33:30 +0000	[thread overview]
Message-ID: <bug-113083-4-u8gqtnp8hq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113083-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As in:
2024-02-22  Jakub Jelinek  <jakub@redhat.com>

        PR c++/113083
        * cp-gimplify.cc (cp_fold): For targetm.cxx.cdtor_returns_this ()
        wrap r into a COMPOUND_EXPR and return folded CALL_EXPR_ARG (x, 0).

        * g++.dg/cpp0x/constexpr-113083.C: New test.

--- gcc/cp/cp-gimplify.cc.jj    2024-02-22 21:45:09.663430066 +0100
+++ gcc/cp/cp-gimplify.cc       2024-02-22 22:30:23.481428242 +0100
@@ -3412,9 +3412,15 @@ cp_fold (tree x, fold_flags_t flags)
            if (DECL_CONSTRUCTOR_P (callee))
              {
                loc = EXPR_LOCATION (x);
-               tree s = build_fold_indirect_ref_loc (loc,
-                                                     CALL_EXPR_ARG (x, 0));
+               tree a = CALL_EXPR_ARG (x, 0);
+               bool return_this = targetm.cxx.cdtor_returns_this ();
+               if (return_this)
+                 a = cp_save_expr (a);
+               tree s = build_fold_indirect_ref_loc (loc, a);
                r = cp_build_init_expr (s, r);
+               if (return_this)
+                 r = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (x), r,
+                                 fold_convert_loc (loc, TREE_TYPE (x), a));
              }
            x = r;
            break;
--- gcc/testsuite/g++.dg/cpp0x/constexpr-113083.C.jj    2024-01-13
00:05:00.077372302 +0100
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-113083.C       2024-02-22
22:20:20.622618992 +0100
@@ -0,0 +1,16 @@
+// PR c++/113083
+// { dg-do compile { target c++11 } }
+// { dg-options "-Os" }
+
+struct A { constexpr A (); };
+
+void
+foo ()
+{
+  A b;
+}
+
+constexpr
+A::A ()
+{
+}

  parent reply	other threads:[~2024-02-22 21:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-19 11:39 [Bug target/113083] New: " mjires at suse dot cz
2023-12-19 12:34 ` [Bug c++/113083] " rguenth at gcc dot gnu.org
2023-12-19 14:11 ` jakub at gcc dot gnu.org
2023-12-19 15:09 ` mpolacek at gcc dot gnu.org
2023-12-19 22:17 ` mpolacek at gcc dot gnu.org
2023-12-20 17:01 ` mpolacek at gcc dot gnu.org
2023-12-22 19:21 ` mpolacek at gcc dot gnu.org
2024-01-10 15:13 ` jason at gcc dot gnu.org
2024-02-22 21:27 ` jakub at gcc dot gnu.org
2024-02-22 21:33 ` jakub at gcc dot gnu.org [this message]
2024-02-23 17:56 ` cvs-commit at gcc dot gnu.org
2024-02-23 17:58 ` 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-113083-4-u8gqtnp8hq@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).