public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/16939] New: Pointers not passed as subroutine arguments
@ 2004-08-09 14:27 paulthomas2 at wanadoo dot fr
  2004-08-14  7:53 ` [Bug fortran/16939] " pinskia at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2004-08-09 14:27 UTC (permalink / raw)
  To: gcc-bugs

! 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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-06-05 22:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-09 14:27 [Bug fortran/16939] New: Pointers not passed as subroutine arguments paulthomas2 at wanadoo dot fr
2004-08-14  7:53 ` [Bug fortran/16939] " pinskia at gcc dot gnu dot org
2004-08-14  7:55 ` pinskia at gcc dot gnu dot org
2004-08-25 22:10 ` tobi at gcc dot gnu dot org
2005-04-06 18:37 ` pinskia at gcc dot gnu dot org
2005-04-06 19:26 ` paulthomas2 at wanadoo dot fr
2005-04-06 19:31 ` paulthomas2 at wanadoo dot fr
2005-05-09 13:55 ` tobi at gcc dot gnu dot org
2005-05-09 16:07 ` paulthomas2 at wanadoo dot fr
2005-05-09 16:08 ` paulthomas2 at wanadoo dot fr
2005-05-29 16:03 ` cvs-commit at gcc dot gnu dot org
2005-06-05  8:59 ` cvs-commit at gcc dot gnu dot org
2005-06-05 22:42 ` pault at gcc dot gnu dot org
2005-06-05 22:43 ` pault at gcc dot gnu dot org
2005-06-05 22:44 ` pault at gcc dot gnu dot org
2005-06-05 22:55 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).