[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 08:10:02 PDT 2024
================
@@ -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() &&
----------------
jeanPerier wrote:
Flang runtime code uses RUNTIME_CHECK macro to control how asserts are emitted inside the runtime.
I am not sure if the check should be in the runtime though. @klausler:
- Does the frontend allows constructing array component whose extent do not fit in SubscriptValue (I guess with PDT that may be hard to enforce in semantics)?
- Is it intended for `SubscriptValue` to be 32 bits while `TypeParameterValue` is 64 bit on 32 bits machine?
https://github.com/llvm/llvm-project/pull/99465
More information about the flang-commits
mailing list