From patchwork Sun Mar 29 16:25:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 455850 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 85A4514008F for ; Mon, 30 Mar 2015 03:26:03 +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=uZA/XhwO; 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=BtNSwEp4556+oqYOg xF21qEpVPWe38veiCspE5/+zB29yBEfn8SiP4sd33UfzdgFtWrCRxvjFUSR/eJh2 pD2vVkxv7vjU/TQobv+jeCWyrpHD5mMcYu9BFIFQhC5kotaKvlLsaSKFTujiswpT H140vDokKIg6pQpHj/iOObKuU8= 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=Bl8sweJUrvrtvtuv/U65DfM EGHQ=; b=uZA/XhwODEUS2qHi3e2ygVmk0GYDBPO3rinDQP+8FmV3QTu7jgupWd+ 8oT/IwRj2UZ2xPMty3oacz6tG9DYozSvznP0j6v5p2NXrw/fnbAqfdsDHUTkb6kQ 8/8dJtsqaQyhaochpjz0yTLZQCqL4+13Z2oUdngPGffc4CB5vTko= Received: (qmail 2548 invoked by alias); 29 Mar 2015 16:25:51 -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 2529 invoked by uid 89); 29 Mar 2015 16:25:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 29 Mar 2015 16:25:49 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id t2TGPlnR095678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 29 Mar 2015 09:25:47 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id t2TGPkin095677; Sun, 29 Mar 2015 09:25:46 -0700 (PDT) (envelope-from sgk) Date: Sun, 29 Mar 2015 09:25:46 -0700 From: Steve Kargl To: Dominique Dhumieres Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: Re: [PATCH] fortran/65429 -- don't dereference a null pointer Message-ID: <20150329162546.GA95666@troutmask.apl.washington.edu> References: <20150328000157.70A50105@mailhost.lps.ens.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150328000157.70A50105@mailhost.lps.ens.fr> User-Agent: Mutt/1.5.23 (2014-03-12) On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote: > > AFAICT your test succeeds without your patch and does not test that the ICE > reported by FX is gone (indeed it is with your patch). > New patch and testcase. The ChangeLog entries are in the original email. Built and tested on x86_64-*-freebsd. OK, now? Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 220943) +++ gcc/fortran/decl.c (working copy) @@ -1404,9 +1404,7 @@ add_init_expr_to_sym (const char *name, } else if (init->expr_type == EXPR_ARRAY) { - gfc_constructor *c; - c = gfc_constructor_first (init->value.constructor); - clen = c->expr->value.character.length; + clen = mpz_get_si (init->ts.u.cl->length->value.integer); sym->ts.u.cl->length = gfc_get_int_expr (gfc_default_integer_kind, NULL, clen); Index: gcc/testsuite/gfortran.dg/pr65429.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr65429.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr65429.f90 (working copy) @@ -0,0 +1,19 @@ +! { dg-do run } +! PR fortran/65429 +program foo + + implicit none + + character(*), parameter :: s(*) = [ character(5) :: 'abcde', 'fghij' ] + character(*), parameter :: t(*) = [ character(31) :: ] + character(*), parameter :: u(*) = [ 'qwerty', 'asdfgh', 'zxcvbn'] + character(*), parameter :: v(*) = ['',''] + + if ((size(s) /= 2).or.(len(s)/=5)) call abort + if ((size(t) /= 0).or.(len(t)/=31)) call abort + if ((size(u) /= 3).or.(len(u)/=6)) call abort + if ((size(v) /= 2).or.(len(v)/=0)) call abort + if ((s(1)/='abcde').or.(s(2)/='fghij')) call abort + if ((u(1)/='qwerty').or.(u(2)/='asdfgh').or.(u(3)/='zxcvbn')) call abort + +end program foo