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/30793] Segfault on calling a function returning a pointer



------- Comment #7 from dominiq at lps dot ens dot fr  2007-02-14 21:54 -------
The following changes

--- pr30793.f90 Wed Feb 14 19:50:03 2007
+++ pr30793_red.f90     Wed Feb 14 22:50:04 2007
@@ -33,7 +33,7 @@
   end type field

   interface msh_
-    module procedure msh_
+    module procedure mshp_
   end interface
   interface create_field
     module procedure create_field
@@ -54,13 +54,13 @@
   end subroutine create_field


-  function msh_(fld)
-    type(mesh), pointer :: msh_
+  function mshp_(fld)
+    type(mesh), pointer :: mshp_
     type(field), intent(in) :: fld

-    msh_ => fld%msh
+    mshp_ => fld%msh

-  end function msh_
+  end function mshp_
 end module class_field

 module class_scalar_field
@@ -147,7 +147,9 @@

   call create_mesh(msh,input_file,'MESH')
   call create_field(quality,msh)
+  print *, "here"                    ! without this => seg fault
   mshp => msh_(quality)
+  print *, size (mshp%area) ! correctly gives 10


 end program test_pnt

make g95 happy and output

 here
 10

Under OSX 10.3 and gfortran powerpc-apple-darwin7, 4.3.0 20070209, I get

 here
Bus error


-- 


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


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