This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 06/27/2011 03:18 PM, Thomas Koenig wrote:Hello world,
the attached patch fixes PR 49479, a regression for 4.7 and 4.6. Test case was supplied by Joost, the approach to the patch was suggested by Tobias in comment#4 of the PR. The patch certainly looks safe enough.
Regression-tested. OK for trunk and, after a couple of days, for 4.6?
Thomas
OK,
After your approval, I realized that I had forgotten the generic reshape. I added that as obvious. Here is what I committed, revision 175594.
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.
PR fortran/49479 * gfortran.dg/reshape_zerosize_3.f90: New test.
Index: m4/reshape.m4 =================================================================== --- m4/reshape.m4 (Revision 175593) +++ m4/reshape.m4 (Arbeitskopie) @@ -101,6 +101,8 @@ if (ret->data == NULL) { + index_type alloc_size; + rs = 1; for (n = 0; n < rdim; n++) { @@ -111,7 +113,13 @@ rs *= rex; } ret->offset = 0; - ret->data = internal_malloc_size ( rs * sizeof ('rtype_name`)); + + if (unlikely (rs < 1)) + alloc_size = 1; + else + alloc_size = rs * sizeof ('rtype_name`); + + ret->data = internal_malloc_size (alloc_size); ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; } Index: intrinsics/reshape_generic.c =================================================================== --- intrinsics/reshape_generic.c (Revision 175593) +++ intrinsics/reshape_generic.c (Arbeitskopie) @@ -85,6 +85,8 @@ if (ret->data == NULL) { + index_type alloc_size; + rs = 1; for (n = 0; n < rdim; n++) { @@ -95,7 +97,14 @@ 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; }
Attachment:
reshape_zerosize_3.f90
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |