public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41022]  New: [4.5.0] problem with procedure pointers
@ 2009-08-10 10:11 reuter at physik dot uni-freiburg dot de
  2009-08-10 10:12 ` [Bug fortran/41022] " reuter at physik dot uni-freiburg dot de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: reuter at physik dot uni-freiburg dot de @ 2009-08-10 10:11 UTC (permalink / raw)
  To: gcc-bugs

It seems that not a pointer is transferred but a value in the following case.
Here is the tracking info:

gfortran -g fptr_transfer.f90 -o fptr_transfer && ./fptr_transfer
Segmentation fault (core dumped)gdb fptr_transfer core
[...]
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000400629 in assign_proc_ptr (ptr=0x0, obj1=( 0x40060c <proc> 
)) at fptr_transfer.f90:32
32          ptr => obj1%proc
(gdb) where
#0  0x0000000000400629 in assign_proc_ptr (ptr=0x0, obj1=( 0x40060c <proc> 
)) at fptr_transfer.f90:32
#1  0x0000000000400687 in transfer_proc_ptr (obj2=( 0 ), obj1=( 0x40060c 
<proc> )) at fptr_transfer.f90:26
#2  0x000000000040064c in foo () at fptr_transfer.f90:19
#3  0x00000000004006c2 in main (argc=1, argv=0x7ffff12d2fe4 
'./fptr_transfer\000') at fptr_transfer.f90:19
#4  0x00007f1d9cdf0586 in __libc_start_main () from /lib64/libc.so.6
#5  0x0000000000400549 in _start () at ../sysdeps/x86_64/elf/start.S:113
Current language:  auto; currently fortran
(gdb)

Here is the corresponding code:
subroutine proc ()
end subroutine proc

program foo

   interface
      subroutine proc ()
      end subroutine proc
   end interface

   type :: container_t
      procedure(proc), nopass, pointer :: proc => null ()
   end type container_t

   type(container_t), target :: obj1
   type(container_t) :: obj2

   obj1%proc => proc
   call transfer_proc_ptr (obj2, obj1)

contains

   subroutine transfer_proc_ptr (obj2, obj1)
     type(container_t), intent(out) :: obj2
     type(container_t), intent(in), target :: obj1
     call assign_proc_ptr (obj2%proc, obj1)
   end subroutine transfer_proc_ptr

   subroutine assign_proc_ptr (ptr, obj1)
     procedure(proc), pointer :: ptr
     type(container_t), intent(in), target :: obj1
     ptr => obj1%proc
   end subroutine assign_proc_ptr

end program foo


-- 
           Summary: [4.5.0] problem with procedure pointers
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reuter at physik dot uni-freiburg dot de
 GCC build triplet: Ref. svn r150253
  GCC host triplet: Linux 32bit, 64bit, MAC OS X
GCC target triplet: fortran 4.5.0


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


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

end of thread, other threads:[~2009-08-12 19:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-10 10:11 [Bug fortran/41022] New: [4.5.0] problem with procedure pointers reuter at physik dot uni-freiburg dot de
2009-08-10 10:12 ` [Bug fortran/41022] " reuter at physik dot uni-freiburg dot de
2009-08-10 12:46 ` janus at gcc dot gnu dot org
2009-08-10 13:41 ` [Bug fortran/41022] [F03] " janus at gcc dot gnu dot org
2009-08-10 13:49 ` janus at gcc dot gnu dot org
2009-08-10 14:14 ` [Bug fortran/41022] [F03] procedure pointer components as actual arguments janus at gcc dot gnu dot org
2009-08-11 20:09 ` janus at gcc dot gnu dot org
2009-08-11 20:15 ` janus at gcc dot gnu dot org
2009-08-12 19:10 ` reuter at physik dot uni-freiburg dot de
2009-08-12 19:22 ` reuter at physik dot uni-freiburg dot de

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).