diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp index 4cf8e92eb5add..5e1233386c608 100644 --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -102,8 +102,10 @@ void RTNAME(PointerAssociateRemapping)(Descriptor &pointer, 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),