From patchwork Sat Nov 23 13:15:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1199826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514462-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="O4gaJX4p"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="c4jJecDu"; 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 47Kv1K65vfz9sPT for ; Sun, 24 Nov 2019 00:15:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ehajyV0Vl61AFcFhqXV2fQ0YpUkBAknLPPLw7t9J4BE0eXPI6Z vYY+LirkJMu92riE2qSvPeAPr1ZhDpISYMGMpWZIiG/sA1T4Jtlj4E/s5cYLbPJd b7dVgfD48v2mE5Z+IHeNJZusZtg+Ef/gzFbpCZB555Bm8GIv64Ciakeqo= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=BaChRraOFZ4ttAkp1eUYyd9ZrIU=; b=O4gaJX4pv5ukrbbeZUyK ubqI3EQG4bklte6lgSPlZ3zb247kJ79u8d+R2Jg31x1hCwBC+b4ZOjagedyZT4b+ o6256fOKkrRcx+Now+lO8cqMEkv3dSJnIJIMrAH4RG3uA2Ris5dHNJPAtEPch+Pz NTSM92fqEU//gWXjDTXChDo= Received: (qmail 125831 invoked by alias); 23 Nov 2019 13:15:26 -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 125778 invoked by uid 89); 23 Nov 2019 13:15:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2219, H*Ad:U*tkoenig, transfer X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Nov 2019 13:15:15 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 3617412632; Sat, 23 Nov 2019 14:15:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1574514908; bh=et1bcTcqsp2lAn5reEFDPoJH+y2T8x2R1QfW2sOxWCE=; h=To:From:Subject:Message-ID:Date:From; b=c4jJecDuEz8xQioTm6I7SmKp0XwmH6iyuoChSjpuAUhjCIhBk5IY1hhZh7128X4q4 7GCGN7EZ2x7QWB9WisT4Hmp+ZsvYVxsqmsCDP6uF38WA0aaF8eW69PDmgb0BlzeFIn 4aTBOm1l6igcKVuzK5RKKYrTb/51txGHp5GaV1gq1vDlm1ViirHrULtsaeCd5DLouz xu3Jp6JfbhQam40/6PRwr6FC6mwLoAGtWl+kk7PTEHx/RiFFvJyCZrMuGFJxt6dGFu C3vaRbGO3EShkLfdTLTGkPAV0xj6m9yDrbTFiUWTJuJEVik+kdrM1vdose5vTnAP0O 7IXMiGSTtU42g== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id 26E4111EE8; Sat, 23 Nov 2019 14:15:08 +0100 (CET) Received: from [2001:4dd6:1e9a:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5dd930dc-669a-7f0000012729-7f0000018198-1 for ; Sat, 23 Nov 2019 14:15:08 +0100 Received: from [IPv6:2001:4dd6:1e9a:0:7285:c2ff:fe6c:992d] (2001-4dd6-1e9a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd6:1e9a:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Sat, 23 Nov 2019 14:15:06 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, libfortran] Fix EOF handling in array I/O Message-ID: Date: Sat, 23 Nov 2019 14:15:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hello world, the attached patch fixes a case where transforming do j = 1,1000 read (20,*,end=1)(tdat(j,k),k=1,10) end do 1 continue which on straight transformation yields DO main:j=1 1000 1 READ UNIT=20 FMT=-1 DO main:k=1 10 1 TRANSFER main:tdat(main:j , main:k) END DO DT_END END=1 END DO 1 CONTINUE into DO main:j=1 1000 1 READ UNIT=20 FMT=-1 TRANSFER main:tdat(main:j , 1:10:1) DT_END END=1 END DO 1 CONTINUE with front-end optimization led to a case where the END statement was not interpreted correctly. The solution, to jump out of transfer_array_inner when the file was at its end, was found by Harald; I just added a NULL pointer check to make some regressions go away. Regression-tested. OK for all affected branches (trunk, gcc 9 and gcc 8)? Regards Thomas Fix EOF handling for arrays. 2019-11-23 Thomas Koenig Harald Anlauf PR fortran/92569 * io/transfer.c (transfer_array_inner): If position is at AFTER_ENDFILE in current unit, return from data loop. 2019-11-23 Thomas Koenig Harald Anlauf PR fortran/92569 * gfortran.dg/eof_4.f90: New test. Index: io/transfer.c =================================================================== --- io/transfer.c (Revision 278025) +++ io/transfer.c (Arbeitskopie) @@ -2544,6 +2544,10 @@ transfer_array_inner (st_parameter_dt *dtp, gfc_ar while (data) { + if (unlikely (dtp->u.p.current_unit + && dtp->u.p.current_unit->endfile == AFTER_ENDFILE)) + return; + dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize); data += stride0 * tsize; count[0] += tsize;