[flang-commits] [flang] [Flang][Runtime] Fix implicit conversion warning when targeting 32bit… (PR #99465)

via flang-commits flang-commits at lists.llvm.org
Fri Jul 19 11:55:01 PDT 2024


https://github.com/serge-sans-paille updated https://github.com/llvm/llvm-project/pull/99465

>From dcf1634197e71966dc1a406e30607ab9c9856d6f 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.
The cast from the internal representation (64bit) to the runtime
representation (32bit) is fine as there shouldn't be a subscript of more
than 32bits on a 32bit architecture.
---
 flang/runtime/derived.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp
index 0d9e033df4e27..659f54fa344bb 100644
--- a/flang/runtime/derived.cpp
+++ b/flang/runtime/derived.cpp
@@ -23,10 +23,9 @@ 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)};
+    extents[dim] = ub >= lb ? static_cast<SubscriptValue>(ub - lb + 1) : 0;
   }
 }
 



More information about the flang-commits mailing list