This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Segfault in dependency code (PR23906)
- From: Paul Brook <paul at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Fri, 16 Sep 2005 04:26:19 +0100
- Subject: [gfortran] Segfault in dependency code (PR23906)
The attached patch fixes a segfault in the dependency code.
The code was dividing the size of the range by the wrong stride (which may be
NULL). The point of this function is to apply the same transformation to both
ranges, so it's definitely the division, and the the condition that's
incorrect.
I also updated the comment to make this clearer.
Tested on i686-linux.
Applied to mainline.
Paul
2005-09-16 Paul Brook <paul@codesourcery.com>
PR fortran/23906
fortran/
* dependency.c (transform_sections): Divide by correct value.
Elaborate comment.
testsuite/
* gfortran.dg/dependency_1.f90: New test.
Index: fortran/dependency.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/dependency.c,v
retrieving revision 1.9
diff -u -p -r1.9 dependency.c
--- fortran/dependency.c 9 Sep 2005 06:34:06 -0000 1.9
+++ fortran/dependency.c 16 Sep 2005 03:10:22 -0000
@@ -392,7 +392,7 @@ get_deps (mpz_t x1, mpz_t x2, mpz_t y)
}
-/* Transforms a sections l and r such that
+/* Perform the same linear transformation on sections l and r such that
(l_start:l_end:l_stride) -> (0:no_of_elements)
(r_start:r_end:r_stride) -> (X1:X2)
Where r_end is implicit as both sections must have the same number of
@@ -434,7 +434,7 @@ transform_sections (mpz_t X1, mpz_t X2,
mpz_mul (X2, no_of_elements, r_stride->value.integer);
if (l_stride != NULL)
- mpz_cdiv_q (X2, X2, r_stride->value.integer);
+ mpz_cdiv_q (X2, X2, l_stride->value.integer);
mpz_add (X2, X2, X1);
return 0;
Index: testsuite/gfortran.dg/dependency_1.f90
===================================================================
RCS file: testsuite/gfortran.dg/dependency_1.f90
diff -N testsuite/gfortran.dg/dependency_1.f90
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gfortran.dg/dependency_1.f90 16 Sep 2005 03:01:51 -0000
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR23906
+! Dependency analysis was using the stride from the wrong expression and
+! segfaulting
+subroutine foo(a)
+ real, dimension(:) :: a
+
+ a(1:3:2) = a(1:2)
+ a(1:2) = a(1:3:2)
+end subroutine
+