diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp index ac12627293aa..9a0168167886 100644 --- a/flang/runtime/transformational.cpp +++ b/flang/runtime/transformational.cpp @@ -167,7 +167,7 @@ void RTNAME(Cshift)(Descriptor &result, const Descriptor &source, } SubscriptValue &sourceDim{sourceAt[dim - 1]}; sourceDim = dimLB + shiftCount % dimExtent; - if (shiftCount < 0) { + if (sourceDim < dimLB) { sourceDim += dimExtent; } for (resDim = 1; resDim <= dimExtent; ++resDim) {