[flang-commits] [flang] ae1d5f4 - [flang][runtime] Reset unit frame buffer when re-opening

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Jul 25 12:18:27 PDT 2022


Author: Peter Klausler
Date: 2022-07-25T12:18:14-07:00
New Revision: ae1d5f4d9da36ebc9c77a2da9f43f3f7e1bf0395

URL: https://github.com/llvm/llvm-project/commit/ae1d5f4d9da36ebc9c77a2da9f43f3f7e1bf0395
DIFF: https://github.com/llvm/llvm-project/commit/ae1d5f4d9da36ebc9c77a2da9f43f3f7e1bf0395.diff

LOG: [flang][runtime] Reset unit frame buffer when re-opening

An OPEN statement that implies closing a connection must invalidate
the unit's frame buffer so as to prevent stale data from the old
connection from being read into the newly-connected unit.

Differential Revision: https://reviews.llvm.org/D130430

Added: 
    

Modified: 
    flang/runtime/unit.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp
index 018c4332415dd..12d8dbc4583a3 100644
--- a/flang/runtime/unit.cpp
+++ b/flang/runtime/unit.cpp
@@ -114,6 +114,7 @@ void ExternalFileUnit::OpenUnit(std::optional<OpenStatus> status,
     // Otherwise, OPEN on open unit with new FILE= implies CLOSE
     DoImpliedEndfile(handler);
     FlushOutput(handler);
+    TruncateFrame(0, handler);
     Close(CloseStatus::Keep, handler);
   }
   if (newPath.get() && newPathLength > 0) {


        


More information about the flang-commits mailing list