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,10 @@ 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{ + static_cast(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),