From patchwork Wed Jul 25 20:08:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 173257 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]) by ozlabs.org (Postfix) with SMTP id EA22F2C009B for ; Thu, 26 Jul 2012 06:08:31 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343851712; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=ugVVoTK ke2blgjGeV1lV5Mldd3U=; b=QKy4W/rnJnA5r3o7hrNmXEPszWbonQMCQk4ubHE 2xlMRqyOTP7bBb603UVWcyvq81oheBjG2uhiepJB64azkjj6spiH+qrT+abBXmOB zidIYPrXDLHBQEjiR5FR6sj8vgJ9zQR6yfJ6upslP7j+/DQ8NZX/4CAgk4OeBWn2 vE4s= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Su1+0zDkAk1LrtXquixqeq93AKZ7Bd5Sz+kCK0LtlIQmJQhM8bzkKN5MQ9AmOq nMy9rXGa5DJXptlkD2cHunw23ilAHm8PxLvTQ7nICnsyXFwuhT8/EqD9lRHixjho p3Lz3t2M0QU5dzTc1lu/SVuDGGW/e8AQjQS5TrCCg6B6c=; Received: (qmail 19995 invoked by alias); 25 Jul 2012 20:08:20 -0000 Received: (qmail 19957 invoked by uid 22791); 25 Jul 2012 20:08:18 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Jul 2012 20:08:03 +0000 Received: from [192.168.178.22] (port-92-204-86-97.dynamic.qsc.de [92.204.86.97]) by mx02.qsc.de (Postfix) with ESMTP id 7836127949; Wed, 25 Jul 2012 22:08:01 +0200 (CEST) Message-ID: <50105221.5060702@net-b.de> Date: Wed, 25 Jul 2012 22:08:01 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, Fortran] Fix module I/O with assumed-rank arrays 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 The following issue was found by Alessandro. (It got triggered by a larger test case, which is required for a larger patch by Alessandro, which is not yet finished.) Accessing the "lower[-1]" is probably not the best idea … Build on x86-64-linux. OK for the trunk? Tobias 2012-07-25 Alessandro Fanfarillo Tobias Burnus * module.c (mio_array_spec): Don't read as->lower for assumed-rank arrays. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index a3b9088..51b7059 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2381,11 +2381,12 @@ mio_array_spec (gfc_array_spec **asp) if (iomode == IO_INPUT && as->corank) as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT; - for (i = 0; i < as->rank + as->corank; i++) - { - mio_expr (&as->lower[i]); - mio_expr (&as->upper[i]); - } + if (as->rank > 0) + for (i = 0; i < as->rank + as->corank; i++) + { + mio_expr (&as->lower[i]); + mio_expr (&as->upper[i]); + } done: mio_rparen ();