From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54085 invoked by alias); 7 Aug 2017 08:47:59 -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 53983 invoked by uid 89); 7 Aug 2017 08:47:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1300 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, 07 Aug 2017 08:47:57 +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 ECB8F7F6A2 for ; Mon, 7 Aug 2017 08:47:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ECB8F7F6A2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=polacek@redhat.com Received: from redhat.com (ovpn-204-44.brq.redhat.com [10.40.204.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6735B8E83A for ; Mon, 7 Aug 2017 08:47:55 +0000 (UTC) Date: Mon, 07 Aug 2017 08:47:00 -0000 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix middle-end/81737 Message-ID: <20170807084751.GC17069@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) X-SW-Source: 2017-08/txt/msg00484.txt.bz2 In my recent change I failed to check whether the type domain of a type is non-NULL and this goof causes crashing on this testcase. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-08-07 Marek Polacek PR middle-end/81737 * fold-const.c (fold_indirect_ref_1): Check type_domain. * gcc.dg/pr81737.c: New test. diff --git gcc/fold-const.c gcc/fold-const.c index d563ba76766..8eaea6cce3a 100644 --- gcc/fold-const.c +++ gcc/fold-const.c @@ -14107,8 +14107,10 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0) && type == TREE_TYPE (op00type)) { tree type_domain = TYPE_DOMAIN (op00type); - tree min = TYPE_MIN_VALUE (type_domain); - if (min && TREE_CODE (min) == INTEGER_CST) + tree min; + if (type_domain != NULL_TREE + && (min = TYPE_MIN_VALUE (type_domain)) + && TREE_CODE (min) == INTEGER_CST) { offset_int off = wi::to_offset (op01); offset_int el_sz = wi::to_offset (TYPE_SIZE_UNIT (type)); diff --git gcc/testsuite/gcc.dg/pr81737.c gcc/testsuite/gcc.dg/pr81737.c index e69de29bb2d..493358956ef 100644 --- gcc/testsuite/gcc.dg/pr81737.c +++ gcc/testsuite/gcc.dg/pr81737.c @@ -0,0 +1,6 @@ +/* PR middle-end/81737 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int a[]; +void fn1() { (a + 0)[1]; } Marek