diff options
author | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2006-10-19 21:48:50 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2006-10-19 21:48:50 +0000 |
commit | 3d894fc3f045e430b67aae82aa68dd818816ac90 (patch) | |
tree | 25894134c7e725dd6026b7d0c821b145999ec721 /libgfortran/intrinsics/cshift0.c | |
parent | 6b7283ac665c92e61ef94de219cf370f44e58c48 (diff) | |
download | gcc-3d894fc3f045e430b67aae82aa68dd818816ac90.zip gcc-3d894fc3f045e430b67aae82aa68dd818816ac90.tar.gz gcc-3d894fc3f045e430b67aae82aa68dd818816ac90.tar.bz2 |
re PR libfortran/27895 (problem with RESHAPE and zero-sized arrays)
PR libfortran/27895
* intrinsics/cshift0.c: Special cases for zero-sized arrays.
* intrinsics/pack_generic.c: Likewise.
* intrinsics/spread_generic.c: Likewise.
* gfortran.dg/zero_sized_1.f90: New test.
From-SVN: r117890
Diffstat (limited to 'libgfortran/intrinsics/cshift0.c')
-rw-r--r-- | libgfortran/intrinsics/cshift0.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c index 4df90ad..f2c2219 100644 --- a/libgfortran/intrinsics/cshift0.c +++ b/libgfortran/intrinsics/cshift0.c @@ -1,5 +1,5 @@ /* Generic implementation of the CSHIFT intrinsic - Copyright 2003, 2005 Free Software Foundation, Inc. + Copyright 2003, 2005, 2006 Free Software Foundation, Inc. Contributed by Feng Wang <wf_cs@yahoo.com> This file is part of the GNU Fortran 95 runtime library (libgfortran). @@ -144,8 +144,8 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array, if (ret->data == NULL) { int i; + index_type arraysize = size0 ((array_t *)array); - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -156,8 +156,17 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array, if (i == 0) ret->dim[i].stride = 1; else - ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride; + ret->dim[i].stride = (ret->dim[i-1].ubound + 1) + * ret->dim[i-1].stride; } + + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + { + ret->data = internal_malloc_size (1); + return; + } } for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) |