From patchwork Thu Mar 26 17:58:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 455183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C4BE114012C for ; Fri, 27 Mar 2015 04:58:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kknaFSTX; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=biiZUURLPrGHF7v26fiFxHui1DhjkYXx6m/Wt84xFGj7py 74VX2IPQ0AXPDf1kE3Ddn4XMLRLutgeQ7ubjl32fV5Jg0QnZbAOJILkG1IWNSXo7 7Uu43dEPENwIvEp706NDmGrzQpx25kEiK0ImQnZGjNTR0/vj4iV8VLGUKnb2A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=yzmubffXaBnORZxo7PWK+vbVIbM=; b=kknaFSTXKSTM2+36DdhN JqkQJT7JSJ4GtaAlJLBmk5dtfYDANbmYxeoVFHglw5N0XvyGXRjk2xLpPIjrgmBp sSwk1jZFLD9maX76G9Lq9bFDBpR/RmaK2DlhGiPWgELPcGZlF1iPjvKs79RlE2AB Lfgn4YXqzUkuhiLVW3oxRfs= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 13:58:29 -0400 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) It's simple enough to make potential_constant_expression_1 handle MEM_REF. Tested x86_64-pc-linux-gnu, applying to trunk. 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; +}