The following code causes segfault on execution. 
(This code works with PGI, Intel, and Hitachi Fortrans)

    module one
    contains
        function foo1(n)
        integer :: n
        integer :: foo1(n)

        call bar1(n, foo1)
        return
        end function

        subroutine bar1(n, array)
          integer :: n
          integer :: array(*)
          integer :: i
          do i = 1, n
             array(i) = i
          enddo
        end subroutine
    end module

    program main
      use one
      integer :: n
      n = 3
      write(*,*) foo1(n)
    end program

If the defnition of function foo1 is modeified as following, The problem
disappear.

        function foo1(n) result(res)
        integer :: n
        integer :: res(n)

        call bar1(n, res)
        return
        end function


-- 
           Summary: function without result clause fails to compile prperly
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rakuen_himawari at yahoo dot co dot jp
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to