diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-28 18:59:04 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-28 18:59:04 +0000 |
commit | 568408e3a3f848fb9b3cb3cf2b80cb9c7012b0b5 (patch) | |
tree | 065be10e884faa1cf29e82bd342b95d03ee62f80 /libgfortran/generated/reshape_i4.c | |
parent | 94bbf49527a6dc8f36a24a97fa3ea21cbd1633bf (diff) | |
download | gcc-568408e3a3f848fb9b3cb3cf2b80cb9c7012b0b5.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175594 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/reshape_i4.c')
-rw-r--r-- | libgfortran/generated/reshape_i4.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c index 53016bdf597..2c136deeae2 100644 --- a/libgfortran/generated/reshape_i4.c +++ b/libgfortran/generated/reshape_i4.c @@ -97,6 +97,8 @@ reshape_4 (gfc_array_i4 * const restrict ret, if (ret->data == NULL) { + index_type alloc_size; + rs = 1; for (n = 0; n < rdim; n++) { @@ -107,7 +109,13 @@ reshape_4 (gfc_array_i4 * const restrict ret, rs *= rex; } ret->offset = 0; - ret->data = internal_malloc_size ( rs * sizeof (GFC_INTEGER_4)); + + if (unlikely (rs < 1)) + alloc_size = 1; + else + alloc_size = rs * sizeof (GFC_INTEGER_4); + + ret->data = internal_malloc_size (alloc_size); ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; } |