Skip to content

Commit 63d8d94

Browse files
[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.
1 parent da0c8b2 commit 63d8d94

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

flang/runtime/derived.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ static RT_API_ATTRS void GetComponentExtents(SubscriptValue (&extents)[maxRank],
2323
const typeInfo::Component &comp, const Descriptor &derivedInstance) {
2424
const typeInfo::Value *bounds{comp.bounds()};
2525
for (int dim{0}; dim < comp.rank(); ++dim) {
26-
SubscriptValue lb{bounds[2 * dim].GetValue(&derivedInstance).value_or(0)};
27-
SubscriptValue ub{
28-
bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0)};
29-
extents[dim] = ub >= lb ? ub - lb + 1 : 0;
26+
auto lb = bounds[2 * dim].GetValue(&derivedInstance).value_or(0);
27+
auto ub = bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0);
28+
if (ub >= lb) {
29+
auto bound_diff = ub - lb;
30+
extents[dim] = static_cast<SubscriptValue>(bound_diff);
31+
} else {
32+
extents[dim] = 0;
33+
}
3034
}
3135
}
3236

0 commit comments

Comments
 (0)