From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130157 invoked by alias); 15 Sep 2019 17:51:29 -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 130141 invoked by uid 89); 15 Sep 2019 17:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy= X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Sep 2019 17:51:28 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x8FHpQjb031227 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 15 Sep 2019 10:51:26 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x8FHpQa1031226; Sun, 15 Sep 2019 10:51:26 -0700 (PDT) (envelope-from sgk) Date: Sun, 15 Sep 2019 17:51:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/91727 -- NULL pointer dereference Message-ID: <20190915175126.GA31193@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="9amGYk9869ThD9tj" Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) X-SW-Source: 2019-09/txt/msg00913.txt.bz2 --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 533 Committed as obvious. The patch checks for a NULL pointer dereference. In this case, it pointers to an error in the Fortran code, and so gfortran now issues an informative error message. 2019-09-15 Steven G. Kargl PR fortran/91727 * resolve.c (conformable_arrays): If array-spec is NULL, then allocate-object is a scalar. a conformability check only occurs for an array source-expr. 2019-09-15 Steven G. Kargl PR fortran/91727 * gfortran.dg/pr91727.f90: New test. -- Steve --9amGYk9869ThD9tj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr91727.diff" Content-length: 1048 Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 275715) +++ gcc/fortran/resolve.c (working copy) @@ -7487,7 +7487,7 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2) for (tail = e2->ref; tail && tail->next; tail = tail->next); /* First compare rank. */ - if ((tail && e1->rank != tail->u.ar.as->rank) + if ((tail && (!tail->u.ar.as || e1->rank != tail->u.ar.as->rank)) || (!tail && e1->rank != e2->rank)) { gfc_error ("Source-expr at %L must be scalar or have the " Index: gcc/testsuite/gfortran.dg/pr91727.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91727.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91727.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +! Code contributed by Gerhard Steinmetz. +program p + type t + class(*), allocatable :: a + end type + type(t) :: x + allocate (x%a, source=[1]) ! { dg-error "have the same rank as" } +end --9amGYk9869ThD9tj--