From patchwork Mon Aug 26 13:35:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1153178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507706-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dMAbiKZu"; dkim-atps=neutral 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 46HCgD6n6Wz9s7T for ; Mon, 26 Aug 2019 23:35:19 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=d71r0/OG7GeWxUR9ZuGuyVtbpsYdqys9RC4gPirOWEjsOG0PQbuff 2BMLv9W5qN913tIk0mBjtLX48rXWxK66vEkfXX7Zl48qR5nU8i0EFA3BXKNTYwhp lMEcLv6QlsKsxsWslm1fbOaF2LqcLAGVALblazDJMo3vaXkyExwyXw= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=1i6sMsf0JBLU8Myj2tk1WqT/2QM=; b=dMAbiKZunq/ZGHXH/mLw i/H73Oyn0YArsprWAKTuTgdQY3GCSG9OIfl7r/HsSVo6go9IxLVZffwo6KeqO+Ad utp9Oh4k5Qcw5UDdg7M6OlAD01QtAzZF6CuIVYTuzAmA59ULgbc8+Vz4ffhbc2qR TiIHsjJ2eD9EYYce2fAS938= Received: (qmail 104808 invoked by alias); 26 Aug 2019 13:35:11 -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 104741 invoked by uid 89); 26 Aug 2019 13:35:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1269 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 ESMTP; Mon, 26 Aug 2019 13:35:10 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60D4830872DD for ; Mon, 26 Aug 2019 13:35:09 +0000 (UTC) Received: from redhat.com (ovpn-120-103.rdu2.redhat.com [10.10.120.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6BB2600CE; Mon, 26 Aug 2019 13:35:08 +0000 (UTC) Date: Mon, 26 Aug 2019 09:35:07 -0400 From: Marek Polacek To: Jason Merrill , GCC Patches Subject: C++ PATCH for c++/91545 - ICE in constexpr store evaluation Message-ID: <20190826133507.GU14737@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Now that DECL_MUTABLE_P checks that it got a FIELD_DECL node, One Does Not Simply Check DECL_P. For an ARRAY_REF, "elt" can be a VAR_DECL. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-08-26 Marek Polacek PR c++/91545 - ICE in constexpr store evaluation. * constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead of DECL_P. * g++.dg/cpp0x/pr91545.C: New test. diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c index dbd0dc3b445..6c547d6d179 100644 --- gcc/cp/constexpr.c +++ gcc/cp/constexpr.c @@ -3849,7 +3849,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, { tree ob = TREE_OPERAND (probe, 0); tree elt = TREE_OPERAND (probe, 1); - if (DECL_P (elt) && DECL_MUTABLE_P (elt)) + if (TREE_CODE (elt) == FIELD_DECL && DECL_MUTABLE_P (elt)) mutable_p = true; if (evaluated && modifying_const_object_p (TREE_CODE (t), probe, mutable_p) diff --git gcc/testsuite/g++.dg/cpp0x/pr91545.C gcc/testsuite/g++.dg/cpp0x/pr91545.C new file mode 100644 index 00000000000..2aa1fa18bd5 --- /dev/null +++ gcc/testsuite/g++.dg/cpp0x/pr91545.C @@ -0,0 +1,5 @@ +// PR c++/91545 +// { dg-do compile { target c++11 } } + +long a[1]; +int d, e { d && (a[d] = 0) };