Skip to content

Commit b009f46

Browse files
[Flang][Runtime] Explicitly convert shift value to SubscriptValue (#99822)
Shift value are within the range of SubscriptValue but the API forces them to 64bits. This assumption doesn't hold for 32bit machine, so add an explicit cast.
1 parent 3921900 commit b009f46

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

flang/runtime/transformational.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ void RTDEF(CshiftVector)(Descriptor &result, const Descriptor &source,
508508
SubscriptValue lb{sourceDim.LowerBound()};
509509
for (SubscriptValue j{0}; j < extent; ++j) {
510510
SubscriptValue resultAt{1 + j};
511-
SubscriptValue sourceAt{lb + (j + shift) % extent};
511+
SubscriptValue sourceAt{
512+
lb + static_cast<SubscriptValue>(j + shift) % extent};
512513
if (sourceAt < lb) {
513514
sourceAt += extent;
514515
}
@@ -619,7 +620,7 @@ void RTDEF(EoshiftVector)(Descriptor &result, const Descriptor &source,
619620
}
620621
SubscriptValue lb{source.GetDimension(0).LowerBound()};
621622
for (SubscriptValue j{1}; j <= extent; ++j) {
622-
SubscriptValue sourceAt{lb + j - 1 + shift};
623+
SubscriptValue sourceAt{lb + j - 1 + static_cast<SubscriptValue>(shift)};
623624
if (sourceAt >= lb && sourceAt < lb + extent) {
624625
CopyElement(result, &j, source, &sourceAt, terminator);
625626
} else if (boundary) {

0 commit comments

Comments
 (0)