[flang-commits] [flang] [Flang][Runtime] Fix implicit conversion warning when targeting 32bit… (PR #99465)
via flang-commits
flang-commits at lists.llvm.org
Thu Jul 18 03:27:57 PDT 2024
https://github.com/serge-sans-paille updated https://github.com/llvm/llvm-project/pull/99465
>From d004a840f9438ecf30395d9797a1e66e2347fd59 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Thu, 18 Jul 2024 12:20:17 +0200
Subject: [PATCH] [Flang][Runtime] Fix implicit conversion warning when
targeting 32bit architecture
On 32 bit systems, TypeParameterValue is 64bit wide while CFI_index_t is 32bit wide.
---
flang/runtime/derived.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp
index 0d9e033df4e27..4674abd793a99 100644
--- a/flang/runtime/derived.cpp
+++ b/flang/runtime/derived.cpp
@@ -23,10 +23,16 @@ static RT_API_ATTRS void GetComponentExtents(SubscriptValue (&extents)[maxRank],
const typeInfo::Component &comp, const Descriptor &derivedInstance) {
const typeInfo::Value *bounds{comp.bounds()};
for (int dim{0}; dim < comp.rank(); ++dim) {
- SubscriptValue lb{bounds[2 * dim].GetValue(&derivedInstance).value_or(0)};
- SubscriptValue ub{
- bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0)};
- extents[dim] = ub >= lb ? ub - lb + 1 : 0;
+ auto lb = bounds[2 * dim].GetValue(&derivedInstance).value_or(0);
+ auto ub = bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0);
+ if (ub >= lb) {
+ auto bound_diff = ub - lb;
+ assert(bound_diff <= std::numeric_limits<SubscriptValue>::max() &&
+ "array bound overflow");
+ extents[dim] = bound_diff;
+ } else {
+ extents[dim] = 0;
+ }
}
}
More information about the flang-commits
mailing list