public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/65525 (ICE with trivial assignment)
Date: Thu, 26 Mar 2015 17:58:00 -0000	[thread overview]
Message-ID: <551448C5.5080200@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

It's simple enough to make potential_constant_expression_1 handle MEM_REF.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 65525.patch --]
[-- Type: text/x-patch, Size: 1384 bytes --]

commit c25738941b9d32a9653bca90a896407667685d91
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 26 13:11:13 2015 -0400

    	PR c++/65525
    	* constexpr.c (potential_constant_expression_1): Handle MEM_REF.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 37b619d..2f09472 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4395,6 +4395,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
     case ARRAY_RANGE_REF:
     case MEMBER_REF:
     case DOTSTAR_EXPR:
+    case MEM_REF:
     binary:
       for (i = 0; i < 2; ++i)
 	if (!RECUR (TREE_OPERAND (t, i), want_rval))
diff --git a/gcc/testsuite/g++.dg/parse/assign1.C b/gcc/testsuite/g++.dg/parse/assign1.C
new file mode 100644
index 0000000..c0138c1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/assign1.C
@@ -0,0 +1,22 @@
+// PR c++/65525
+
+struct A
+{
+    int x;
+    char y; // Actually, short and bool (types smaller than int?) trigger this ICE too
+    // Also: the problem doesn't occur if you put the smaller type first, e.g. "char x; int y;"
+
+    A(int x) {} // custom ctor needed for ICE
+};
+
+int main()
+{
+    A a(0), x(1), y(2);
+
+    x = a; // OK
+    y = a; // OK
+    x = y = a; // ICE: sorry, unimplemented: unexpected AST of kind mem_ref
+    // internal compiler error: in potential_constant_expression_1, at cp/constexpr.c:4432
+
+    return 0;
+}

                 reply	other threads:[~2015-03-26 17:58 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=551448C5.5080200@redhat.com \
    --to=jason@redhat.com \
    --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).