From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F2FC13858C52; Sun, 25 Sep 2022 20:56:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2FC13858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664139382; bh=MPwjYjy0q1Ga0BSQbSMEx5ZWW/OjJpNUKmOdcP0qWz4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pOWlkkSG9criAGYgfamiaZr6MsNN0QU9jMjfr/HUhafj3ghJ8cMx4iIfCoH4mgIs0 Q9HZzhBlgzkvdWhE3Jk9Eh16nTbM3EFc8ff2WpuabJUCX6Jls90PFRlZZsRJr1520B ckYqFzXQlgn74Zo9GAlMZNyYB4KH21uCXUYIACzk= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/107031] endfile truncates file at wrong position Date: Sun, 25 Sep 2022 20:56:22 +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 #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 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 > I read "as the next record", not "after the next record". >=20 > gfortran differs here from Intel, NAG, Nvidia, AMD Flang, Crayftn. 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'.=