This is the mail archive of the gcc-bugs@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]

[Bug fortran/12841] [gfortran] passing null to a subroutine


------- Additional Comments From tobi at gcc dot gnu dot org  2004-05-31 22:30 -------
The compile time error can be cured by the appended patch, which effectively
disables type/rank checking for the NULL pointer.

This fixes the bug, but the testcase exposes another bug, it still doesn't work
as apparently some confusion between pass-by-reference and pass-by-value occurs
(the same as in PR 15754): The modified testcase
   MODULE T
   PUBLIC :: A
   CONTAINS
   SUBROUTINE A(B)
   REAL, POINTER :: B
   B => NULL() ! <--------------------------- line added
   IF (ASSOCIATED(B)) CALL ABORT()
   END SUBROUTINE A
   END MODULE T
   USE T
   CALL A(NULL())
   END
works (i.e. it doesn't abort at runtime), whereas the original doesn't work.

Index: interface.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/interface.c,v
retrieving revision 1.4
diff -u -p -r1.4 interface.c
--- interface.c 27 May 2004 12:35:12 -0000      1.4
+++ interface.c 31 May 2004 22:10:14 -0000
@@ -1096,7 +1096,8 @@ compare_parameter (gfc_symbol * formal,
       return compare_interfaces (formal, actual->symtree->n.sym, 0);
     }
  
-  if (!gfc_compare_types (&formal->ts, &actual->ts))
+  if (actual->expr_type != EXPR_NULL
+      && !gfc_compare_types (&formal->ts, &actual->ts))
     return 0;
  
   if (symbol_rank (formal) == actual->rank)
@@ -1235,7 +1236,8 @@ compare_actual_formal (gfc_actual_arglis
          return 0;
        }
  
-      if (compare_pointer (f->sym, a->expr) == 0)
+      if (a->expr->expr_type != EXPR_NULL
+         && compare_pointer (f->sym, a->expr) == 0)
        {
          if (where)
            gfc_error ("Actual argument for '%s' must be a pointer at %L",


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12841


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