From cf3b032b8fb681516ccacbe3689f1cad43a1773a Mon Sep 17 00:00:00 2001
From: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date: Fri, 12 May 2023 12:23:00 -0700
Subject: [PATCH] Fortran: Initialize last_char for internal units.

	PR fortran/109662

libgfortran/ChangeLog:

	* io/unit.c (set_internal_unit): Set the internal unit
	last_char to zero so that previous EOF characters do not
	influence the next read.
---
 libgfortran/io/unit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 82664dc5f98b..36d025949c21 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -504,6 +504,7 @@ set_internal_unit (st_parameter_dt *dtp, gfc_unit *iunit, int kind)
   iunit->current_record=0;
   iunit->read_bad = 0;
   iunit->endfile = NO_ENDFILE;
+  iunit->last_char = 0;
 
   /* Set flags for the internal unit.  */
 
-- 
GitLab