public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gdcproject.org>
To: gcc-patches@gcc.gnu.org
Subject: [committed] d: Fix ICE in in add_stack_var, at cfgexpand.cc:476 (PR106555)
Date: Mon,  8 Aug 2022 20:30:34 +0200	[thread overview]
Message-ID: <20220808183034.817887-1-ibuclaw@gdcproject.org> (raw)

Hi,

This patch fixes the ICE reported in PR d/106555.

The type that triggers the ICE never got completed by the semantic
analysis pass.  Checking for size forces it to be done, or issue a
compile-time error.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32,
committed to mainline, and backported to the releases/gcc-12 branch.

Regards,
Iain.

---
	PR d/106555

gcc/d/ChangeLog:

	* d-target.cc (Target::isReturnOnStack): Check for return type size.

gcc/testsuite/ChangeLog:

	* gdc.dg/imports/pr106555.d: New test.
	* gdc.dg/pr106555.d: New test.
---
 gcc/d/d-target.cc                       |  2 ++
 gcc/testsuite/gdc.dg/imports/pr106555.d | 10 ++++++++++
 gcc/testsuite/gdc.dg/pr106555.d         |  4 ++++
 3 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr106555.d
 create mode 100644 gcc/testsuite/gdc.dg/pr106555.d

diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index 610be74ad48..d4350e593e4 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -464,6 +464,8 @@ Target::isReturnOnStack (TypeFunction *tf, bool)
     return false;
 
   Type *tn = tf->next->toBasetype ();
+  if (tn->size () == SIZE_INVALID)
+    return false;
 
   return (tn->ty == TY::Tstruct || tn->ty == TY::Tsarray);
 }
diff --git a/gcc/testsuite/gdc.dg/imports/pr106555.d b/gcc/testsuite/gdc.dg/imports/pr106555.d
new file mode 100644
index 00000000000..0d3ab6bb747
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr106555.d
@@ -0,0 +1,10 @@
+module imports.pr106555;
+struct S106555
+{
+    int[] f106555;
+    int max106555;
+    this(int)
+    {
+        f106555.length = max106555;
+    }
+}
diff --git a/gcc/testsuite/gdc.dg/pr106555.d b/gcc/testsuite/gdc.dg/pr106555.d
new file mode 100644
index 00000000000..7b40f3c097b
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr106555.d
@@ -0,0 +1,4 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106555
+// { dg-do compile }
+// { dg-additional-options "-O2" }
+// { dg-additional-sources "imports/pr106555.d" }
-- 
2.34.1


                 reply	other threads:[~2022-08-08 18:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220808183034.817887-1-ibuclaw@gdcproject.org \
    --to=ibuclaw@gdcproject.org \
    --cc=gcc-patches@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).