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]

Re: [Patch,fortran] Make assoicated(null-pointer-to-array,null-pointer-to-array) return .FALSE.


And as Sunday bonus: Also with a patch.

Tobias Burnus wrote:
> :ADDPATCH fortran:
>
> This fixes CP2K. Calling
>    associated(pointer,target)
> returned .TRUE., if both pointer and target were NULL.
>
> This patch fixes this in the libgfortran library.
>
> (As I just found out, the same problem exists also for scalars [if
> expression added in trans-intrinsic]; this is PR 30238. I don't have the
> time too look at it at the moment.)
>
> Regression tested on x86_64-unknown-linux-gnu. Ok for the trunk and gcc
> 4.2? (Maybe also for 4.1?)
>
> Tobias
>
>
> 2006-12-17  Tobias Burnus  <burnus@net-b.de>
>
>     * intrinsics/associated.c: Check for associated(NULL,NULL).
>
> 2006-12-17  Tobias Burnus  <burnus@net-b.de>
>
>     * gfortran.dg/associated_2.f90: Add test for associated(NULL,NULL).
>
>   

Index: libgfortran/intrinsics/associated.c
===================================================================
--- libgfortran/intrinsics/associated.c	(Revision 119983)
+++ libgfortran/intrinsics/associated.c	(Arbeitskopie)
@@ -39,6 +39,8 @@
 {
   int n, rank;
 
+  if (GFC_DESCRIPTOR_DATA (pointer) == NULL)
+    return 0;
   if (GFC_DESCRIPTOR_DATA (pointer) != GFC_DESCRIPTOR_DATA (target))
     return 0;
   if (GFC_DESCRIPTOR_DTYPE (pointer) != GFC_DESCRIPTOR_DTYPE (target))
Index: gcc/testsuite/gfortran.dg/associated_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/associated_2.f90	(Revision 119983)
+++ gcc/testsuite/gfortran.dg/associated_2.f90	(Arbeitskopie)
@@ -17,6 +17,8 @@
 ! the target argument is not present (case (i))
     if (.not. associated (b)) call abort ()
     deallocate (a)
+    nullify(a)
+    if(associated(a,a)) call abort()
     allocate (a(2,1,2))
     b => a
     if (.not.associated (b)) call abort ()

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