[flang-commits] [flang] [Flang][Runtime] Explicitly convert shift value to SubscriptValue (PR #99822)
via flang-commits
flang-commits at lists.llvm.org
Sun Jul 21 12:21:38 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: None (serge-sans-paille)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/99822.diff
1 Files Affected:
- (modified) flang/runtime/transformational.cpp (+3-2)
``````````diff
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index cf1e61c0844d8..b6b204be4418c 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -508,7 +508,8 @@ void RTDEF(CshiftVector)(Descriptor &result, const Descriptor &source,
SubscriptValue lb{sourceDim.LowerBound()};
for (SubscriptValue j{0}; j < extent; ++j) {
SubscriptValue resultAt{1 + j};
- SubscriptValue sourceAt{lb + (j + shift) % extent};
+ SubscriptValue sourceAt{
+ lb + static_cast<SubscriptValue>(j + shift) % extent};
if (sourceAt < lb) {
sourceAt += extent;
}
@@ -619,7 +620,7 @@ void RTDEF(EoshiftVector)(Descriptor &result, const Descriptor &source,
}
SubscriptValue lb{source.GetDimension(0).LowerBound()};
for (SubscriptValue j{1}; j <= extent; ++j) {
- SubscriptValue sourceAt{lb + j - 1 + shift};
+ SubscriptValue sourceAt{lb + j - 1 + static_cast<SubscriptValue>(shift)};
if (sourceAt >= lb && sourceAt < lb + extent) {
CopyElement(result, &j, source, &sourceAt, terminator);
} else if (boundary) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/99822
More information about the flang-commits
mailing list