diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-06-28 18:59:04 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-06-28 18:59:04 +0000 |
commit | 19b76346c046b95ee4360a5c35d1e3a846aba6f4 (patch) | |
tree | 065be10e884faa1cf29e82bd342b95d03ee62f80 /libgfortran/intrinsics | |
parent | 6138f9bd8783881a1bd7dcfb917a3bfcefcf8cf9 (diff) | |
download | gcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.zip gcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.tar.gz gcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.tar.bz2 |
re PR fortran/49479 (reshape / optionals / zero sized arrays)
2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49479
* m4/reshape.m4: If source allocation is smaller than one, set it
to one.
* intrinsics/reshape_generic.c: Likewise.
* generated/reshape_r16.c: Regenerated.
* generated/reshape_c4.c: Regenerated.
* generated/reshape_c16.c: Regenerated.
* generated/reshape_c8.c: Regenerated.
* generated/reshape_r4.c: Regenerated.
* generated/reshape_i4.c: Regenerated.
* generated/reshape_r10.c: Regenerated.
* generated/reshape_r8.c: Regenerated.
* generated/reshape_c10.c: Regenerated.
* generated/reshape_i8.c: Regenerated.
* generated/reshape_i16.c: Regenerated.
2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49479
* gfortran.dg/reshape_zerosize_3.f90: New test.
From-SVN: r175594
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r-- | libgfortran/intrinsics/reshape_generic.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c index bb1552aa..5b39711 100644 --- a/libgfortran/intrinsics/reshape_generic.c +++ b/libgfortran/intrinsics/reshape_generic.c @@ -85,6 +85,8 @@ reshape_internal (parray *ret, parray *source, shape_type *shape, if (ret->data == NULL) { + index_type alloc_size; + rs = 1; for (n = 0; n < rdim; n++) { @@ -95,7 +97,14 @@ reshape_internal (parray *ret, parray *source, shape_type *shape, rs *= rex; } ret->offset = 0; - ret->data = internal_malloc_size ( rs * size ); + + if (unlikely (rs < 1)) + alloc_size = 1; + else + alloc_size = rs * size; + + ret->data = internal_malloc_size (alloc_size); + ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; } |