This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/16939] New: Pointers not passed as subroutine arguments
- From: "paulthomas2 at wanadoo dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Aug 2004 14:27:28 -0000
- Subject: [Bug fortran/16939] New: Pointers not passed as subroutine arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
! This compiles OK but gives gibberish output or segmentation faults. It seems
! that pointers are not being transferred correctly between sub-programs
! copyright 1996 Loren P. Meissner -- May be distributed if this line is included.
! Earlier versions of ELF failed because INTENT was not declared for pointers.
program Pointer_Arg_Intent
implicit none
integer, parameter :: Str_Len = 15
character (len = Str_Len), pointer :: Root
nullify (Root)
call Create (Root)
! print *, Root !causes segmentation fault at runtime
print *, Get_Target (Root) !outputs gibberish
stop
contains
subroutine Create (Temp_Ptr)
character (len = Str_Len), pointer :: Temp_Ptr
character (len = Str_Len), pointer :: New_Item
allocate (New_Item)
New_Item = " A NEW STRING "
Temp_Ptr => New_Item
print *, Temp_ptr !works OK
return
end subroutine Create
function Get_Target (Temp_Ptr) result (String)
character (len = Str_Len), pointer :: Temp_Ptr
character (len = Str_Len) :: String
String = Temp_Ptr
return
end function Get_Target
end program Pointer_Arg_Intent
--
Summary: Pointers not passed as subroutine arguments
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: paulthomas2 at wanadoo dot fr
CC: bdavis at gcc dot gnu dot org,gcc-bugs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16939