diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp --- a/flang/runtime/transformational.cpp +++ b/flang/runtime/transformational.cpp @@ -167,7 +167,7 @@ } SubscriptValue &sourceDim{sourceAt[dim - 1]}; sourceDim = dimLB + shiftCount % dimExtent; - if (shiftCount < 0) { + if (sourceDim < dimLB) { sourceDim += dimExtent; } for (resDim = 1; resDim <= dimExtent; ++resDim) {