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]

[PATCH] Fix PR fortran/44135


The attached patch has been regtested on x86_64-*-freebsd.

The problem is an invalid computation of an array size 
due to using mpz_get_ui() to retrieve the array dimensions
where the array is A(-2:0).  Using mpz_get_si() corrects
the issue.

OK for trunk?
OK for 4.4 and 4.5 trunk when my regtesting completes?


2010-05-14  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/44135
	* gfortran.dg/actual_array_interface_2.f90: New test.

2010-05-14  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/44135
	* fortran/interface.c (get_sym_storage_size): Use signed instead of
	unsigned mpz_get_?i routines.

-- 
Steve
Index: testsuite/gfortran.dg/actual_array_interface_2.f90
===================================================================
--- testsuite/gfortran.dg/actual_array_interface_2.f90	(revision 0)
+++ testsuite/gfortran.dg/actual_array_interface_2.f90	(revision 0)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+program gprogram
+   implicit none
+   real, dimension(-2:0) :: my_arr
+   call fill_array(my_arr)
+   contains
+      subroutine  fill_array(arr)
+         implicit none
+         real, dimension(-2:0), intent(out) :: arr
+         arr = 42
+      end subroutine fill_array
+end program gprogram
+
Index: fortran/interface.c
===================================================================
--- fortran/interface.c	(revision 159238)
+++ fortran/interface.c	(working copy)
@@ -1645,8 +1645,8 @@ get_sym_storage_size (gfc_symbol *sym)
 	  || sym->as->lower[i]->expr_type != EXPR_CONSTANT)
 	return 0;
 
-      elements *= mpz_get_ui (sym->as->upper[i]->value.integer)
-		  - mpz_get_ui (sym->as->lower[i]->value.integer) + 1L;
+      elements *= mpz_get_si (sym->as->upper[i]->value.integer)
+		  - mpz_get_si (sym->as->lower[i]->value.integer) + 1L;
     }
 
   return strlen*elements;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]