summaryrefslogtreecommitdiff
path: root/libgfortran/runtime
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2021-06-22 12:42:17 -0700
committerSandra Loosemore <sandra@codesourcery.com>2021-06-22 12:45:47 -0700
commitf61e5d4d8b6d4cfa96863187fa61b8c6b057a491 (patch)
treec72c4ba437b68586b2435717827e48bc7b8a317c /libgfortran/runtime
parente02840c1a92abecd211ffaf05b28329bcb534583 (diff)
downloadgcc-f61e5d4d8b6d4cfa96863187fa61b8c6b057a491.tar.gz
Fortran: fix sm computation in CFI_allocate [PR93524]
This patch fixes a bug in setting the step multiplier field in the C descriptor for array dimensions > 2. 2021-06-21 Sandra Loosemore <sandra@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> libgfortran/ PR fortran/93524 * runtime/ISO_Fortran_binding.c (CFI_allocate): Fix sm computation. gcc/testsuite/ PR fortran/93524 * gfortran.dg/pr93524.c: New. * gfortran.dg/pr93524.f90: New.
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r--libgfortran/runtime/ISO_Fortran_binding.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
index 20833ad2025..09788321c9e 100644
--- a/libgfortran/runtime/ISO_Fortran_binding.c
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -254,10 +254,7 @@ CFI_allocate (CFI_cdesc_t *dv, const CFI_index_t lower_bounds[],
{
dv->dim[i].lower_bound = lower_bounds[i];
dv->dim[i].extent = upper_bounds[i] - dv->dim[i].lower_bound + 1;
- if (i == 0)
- dv->dim[i].sm = dv->elem_len;
- else
- dv->dim[i].sm = dv->elem_len * dv->dim[i - 1].extent;
+ dv->dim[i].sm = dv->elem_len * arr_len;
arr_len *= dv->dim[i].extent;
}
}