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]

Fix gfortran.dg/realloc_on_assign_2.f03 (was: Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables)


On 11/30/2010 05:47 PM, Paul Richard Thomas wrote:
And as "xwrkt =invima (...)" only sets one element, all other elements are
undefined according to the Fortran standard.  But, using SUM, one accesses
all elements.
Absolutely right - that's the point, isn't it?
Thus, your patch is correct.

Committed as Rev. 167305.


And to answer my question: For the function result an new array temporary will be malloced - hence the wrong results. Thus, there is an abort with MALLOC_PERTURB_ and thus valgrind shows uninitialized variables.

Tobias
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 167304)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2010-11-30  Tobias Burnus  <burnus@net-b.de>
+
+	* gfortran.dg/realloc_on_assign_2.f03 (invima): Assign
+	a value to all array elements.
+
 2010-11-30  Richard Guenther  <rguenther@suse.de>
 
 	PR tree-optimization/46722
Index: gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03
===================================================================
--- gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03	(revision 167304)
+++ gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03	(working copy)
@@ -114,6 +114,7 @@
     real, dimension (1:m,1:m)              :: invima
     real, dimension (1:m,1:m), intent (in) :: a
     integer, intent (in)            :: j, k
+    invima = 0.0
     invima (j, j) = 1.0 / (1.0 - a (j, j))
   end function invima
   subroutine test6

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