Skip to content

Commit d004a84

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.
1 parent da0c8b2 commit d004a84

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

flang/runtime/derived.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ 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+
assert(bound_diff <= std::numeric_limits<SubscriptValue>::max() &&
31+
"array bound overflow");
32+
extents[dim] = bound_diff;
33+
} else {
34+
extents[dim] = 0;
35+
}
3036
}
3137
}
3238

0 commit comments

Comments
 (0)