--- Begin Message ---
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: fortran at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Sun, 27 Jan 2008 14:14:49 +0100
- Subject: [patch, libfortran] Fix PR 34980
Hello world,
this fixes PR 34980, a 4.3 regression.
In the PR, there is a comment from Tobias B. with an alternate approach.
I was already into testing my patch when I read that comment, which is
why I didn't pursue that approach further. I have to admit that I feel
better about adding something that's obviously (to me) correct to a
library function than to do this in the front end.
Regression-tested on i686-pc-linux-gnu. OK for trunk?
Thomas
2008-01-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34980
* m4/shape.m4: If return array is empty, return early.
* generated/shape_i4.c: Regenerated.
* generated/shape_i8.c: Regenerated.
* generated/shape_i16.c: Regenerated.
2008-01-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34980
* gfortran.dg/shape_3.f90: New test.
Index: m4/shape.m4
===================================================================
--- m4/shape.m4 (revision 131874)
+++ m4/shape.m4 (working copy)
@@ -49,6 +49,9 @@ shape_'rtype_kind` ('rtype` * const rest
stride = ret->dim[0].stride;
+ if (ret->dim[0].ubound < ret->dim[0].lbound)
+ return;
+
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{
ret->data[n * stride] =
! { dg-do run }
! PR 34980 - we got a segfault for calling shape
! with a scalar.
program main
integer :: n
n = 5
open(10,status="scratch")
write (10,*) shape(n)
close(10,status="delete")
end
--- End Message ---