diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp index 7fcb90072e754..843f9165f8554 100644 --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -165,8 +165,9 @@ bool RTNAME(PointerIsAssociatedWith)( for (int j{0}; j < rank; ++j) { const Dimension &pDim{pointer.GetDimension(j)}; const Dimension &tDim{target->GetDimension(j)}; - if (pDim.Extent() != tDim.Extent() || - pDim.ByteStride() != tDim.ByteStride()) { + auto pExtent{pDim.Extent()}; + if (pExtent == 0 || pExtent != tDim.Extent() || + (pExtent != 1 && pDim.ByteStride() != tDim.ByteStride())) { return false; } }