From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130676 invoked by alias); 26 Mar 2015 17:58:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 130609 invoked by uid 89); 26 Mar 2015 17:58:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Mar 2015 17:58:34 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AF7D3C1EEE for ; Thu, 26 Mar 2015 17:58:33 +0000 (UTC) Received: from [10.10.116.31] ([10.10.116.31]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2QHwX67027872 for ; Thu, 26 Mar 2015 13:58:33 -0400 Message-ID: <551448C5.5080200@redhat.com> Date: Thu, 26 Mar 2015 17:58:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/65525 (ICE with trivial assignment) Content-Type: multipart/mixed; boundary="------------010909050407000909080503" X-SW-Source: 2015-03/txt/msg01387.txt.bz2 This is a multi-part message in MIME format. --------------010909050407000909080503 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 123 It's simple enough to make potential_constant_expression_1 handle MEM_REF. Tested x86_64-pc-linux-gnu, applying to trunk. --------------010909050407000909080503 Content-Type: text/x-patch; name="65525.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="65525.patch" Content-length: 1384 commit c25738941b9d32a9653bca90a896407667685d91 Author: Jason Merrill 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; +} --------------010909050407000909080503--