diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -102,8 +102,9 @@ 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) { + std::size_t boundsRank{bounds.GetDimension(1).Extent()}; + pointer.raw().rank = boundsRank; + for (int j{0}; j < boundsRank; ++j) { auto &dim{pointer.GetDimension(j)}; dim.SetBounds(GetInt64(bounds.ZeroBasedIndexedElement(2 * j), boundElementBytes, terminator),