From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 803AA3858C52; Mon, 26 Sep 2022 00:18:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 803AA3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664151511; bh=UlFJ5ibLnwUbCriPps/xevACMLENvr1+RpeoAeQ2TJ8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n1gCph7VSIIqxQmhGCiryhQyLZdLfrLMoAI7bl4mqrHi3SJduCCb3rRFCEtgMB+Fw z0/nk6hgSbBjYTsKS11fWGjTX/lCLvNLTuSFLuxi7w9QUEYmreo8yzF3tBlHedrgLY u0JvMLp/DrIrnm4P1IjgMQibrjthBSm6qA6WMPGU= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/107031] endfile truncates file at wrong position Date: Mon, 26 Sep 2022 00:18:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107031 --- Comment #5 from Steve Kargl -= -- On Sun, Sep 25, 2022 at 08:56:22PM +0000, kargl at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107031 >=20 > --- Comment #4 from kargl at gcc dot gnu.org --- > (In reply to anlauf from comment #3) > > (In reply to kargl from comment #2) > > > gfortran's current behavior is correct. > > >=20 > > >=20 > > > 12.3.4.4 File position after data transfer > > >=20 > > > In all other cases, the file is positioned after the record just > > > read or written and that record becomes the preceding record. > > >=20 > > > 12.8.3 ENDFILE statement > > >=20 > > > Execution of an ENDFILE statement for a file connected for sequent= ial > > > access writes an endfile record as the next record of the file. > > >=20 > > > After reading '5', the file is position at the record that contains '= 6'. > > > So, ENDIFLE writes the endfile record after the record with '6'. > >=20 > > Hmm, interpretation of text? > >=20 > > I read "as the next record", not "after the next record". > >=20 > > gfortran differs here from Intel, NAG, Nvidia, AMD Flang, Crayftn. >=20 > If the current record contain '6', the next record contains '7'. > 'next' does not mean 'current' in the English language. It means > something that 'follows'. >=20 Further confusion, maybe? 12.3.4 File position 12.3.4.1 General ... Let n be the number of records in the file. ... If 1 <=3D i < n and a file is positioned within the ith record or between the ith and (i + 1)th record, the (i + 1)th record is the next record.=