diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -102,6 +102,7 @@ Terminator terminator{sourceFile, sourceLine}; SubscriptValue byteStride{/*captured from first dimension*/}; std::size_t boundElementBytes{bounds.ElementBytes()}; + pointer.raw().rank = bounds.rank(); for (int j{0}; j < bounds.rank(); ++j) { auto &dim{pointer.GetDimension(j)}; dim.SetBounds(GetInt64(bounds.ZeroBasedIndexedElement(2 * j), @@ -109,7 +110,7 @@ GetInt64(bounds.ZeroBasedIndexedElement(2 * j + 1), boundElementBytes, terminator)); if (j == 0) { - byteStride = dim.ByteStride(); + byteStride = dim.ByteStride() * dim.Extent(); } else { dim.SetByteStride(byteStride); byteStride *= dim.Extent();