[flang-commits] [PATCH] D85863: [flang] Descriptor-based I/O using wrong size for contiguous unformatted I/O

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Aug 13 10:47:29 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c9aca1e9396: [flang] Descriptor-based I/O using wrong size for contiguous unformatted I/O (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85863/new/

https://reviews.llvm.org/D85863

Files:
  flang/runtime/descriptor-io.h
  flang/runtime/descriptor.h


Index: flang/runtime/descriptor.h
===================================================================
--- flang/runtime/descriptor.h
+++ flang/runtime/descriptor.h
@@ -255,6 +255,7 @@
     }
   }
 
+  // Returns size in bytes of the descriptor (not the data)
   static constexpr std::size_t SizeInBytes(
       int rank, bool addendum = false, int lengthTypeParameters = 0) {
     std::size_t bytes{sizeof(Descriptor) - sizeof(Dimension)};
Index: flang/runtime/descriptor-io.h
===================================================================
--- flang/runtime/descriptor-io.h
+++ flang/runtime/descriptor-io.h
@@ -223,16 +223,16 @@
     std::size_t elementBytes{descriptor.ElementBytes()};
     SubscriptValue subscripts[maxRank];
     descriptor.GetLowerBounds(subscripts);
+    std::size_t numElements{descriptor.Elements()};
     if (descriptor.IsContiguous()) { // contiguous unformatted I/O
       char &x{ExtractElement<char>(io, descriptor, subscripts)};
-      auto totalBytes{descriptor.SizeInBytes()};
+      auto totalBytes{numElements * elementBytes};
       if constexpr (DIR == Direction::Output) {
         return unf->Emit(&x, totalBytes, elementBytes);
       } else {
         return unf->Receive(&x, totalBytes, elementBytes);
       }
     } else { // non-contiguous unformatted I/O
-      std::size_t numElements{descriptor.Elements()};
       for (std::size_t j{0}; j < numElements; ++j) {
         char &x{ExtractElement<char>(io, descriptor, subscripts)};
         if constexpr (DIR == Direction::Output) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85863.285424.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200813/445328e3/attachment.bin>


More information about the flang-commits mailing list