This is a bug that is specific to functions where RESULT is specified in the
function statement(function foo).  In this case, the pointer itself is
printed.

Where RESULT is not specified, functions return a pointer result
correctly(function bar).  Here the value pointed too is printed.

$ cat   return_pointer.f90
! Test the return of  pointer
program ret_ptr
  print *, foo (99) , " from function foo (arg) result (ptr)"
  print *, bar (99) , " from function bar (arg)"
contains
  function foo (arg) result(ptr)
    integer :: arg
    integer, pointer :: ptr
    allocate (ptr)
    ptr = arg
  end function foo
  function bar (arg)
    integer :: arg
    integer, pointer :: bar
    allocate (bar)
    bar = arg
  end function bar
end  program ret_ptr

$ ./a
   168034328  from function foo (arg) result (ptr)
          99  from function bar (arg)

-- 
           Summary: pointer function with RESULT specified returns pointer
                    to "ptr" rather than "*ptr"
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paulthomas2 at wanadoo dot fr
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to