[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:06 PDT 2024
https://github.com/serge-sans-paille created https://github.com/llvm/llvm-project/pull/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.
>From 20d684cc87db4bf8854c02af229b4fe370fdf095 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Sun, 21 Jul 2024 21:15:43 +0200
Subject: [PATCH] [Flang][Runtime] Explicitly convert shift value to
SubscriptValue
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.
---
flang/runtime/transformational.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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) {
More information about the flang-commits
mailing list