From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D959A385828F; Mon, 26 Sep 2022 14:33:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D959A385828F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664202782; bh=w6gQdOYfazIJ2G63Zq4umjR1NCFNb9jjLPcm/Z71Xlk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fosM4Zigi98W+HfkyAyRWliJpFA8PfYgiUg4+nVZ42Q8953oeeNhHb0GsnuUP5opR 1VBdDlJfQNRTrMgfuXZLo68gY5krfIfxj8E0MNmMWnrSXZK4O95VdldY2PRi4n/74Y bZXf10fcfIIzuGQkair+kFtBL4YAYq9r9C3SfORY= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/107031] endfile truncates file at wrong position Date: Mon, 26 Sep 2022 14:33:01 +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: kargl at gcc dot gnu.org 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 #6 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 sequential > > 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 Yes, it is interpretation. Let denote the start of record and the end of the record. One has=20 567 After reading '5', the file is positioned to after that record. If * denot= es the current file, then one can have 5*6 or 5*6 Both meet the requirement of 12.3.4.4. Now by 12.8.3, the endfile will give 5EOF while the latter would give 5*6EOF.=