module mman implicit none private public mskew,nskew contains function nskew() result(y) real :: y(1) call skewm(y) end function nskew ! function mskew() real :: mskew(1) call skewm(mskew) end function mskew ! subroutine skewm(smat) real, intent(out) :: smat(1) smat = 0.0 end subroutine skewm end module mman ! program mtst use mman, only: mskew,nskew implicit none print*,"(1) calling nskew" print*,nskew() print*,"(2) calling mskew" print*,mskew() print*,"(3) done" end program mtst
Compiling with mingw gfortran 20070506 with the default options gives the incorrect warning message xfunc_bug.f90: In function 'mskew': xfunc_bug.f90:13: warning: Function does not return a value and at run time the output is (1) calling nskew 0.000000 (2) calling mskew <crash> -- Summary: crash for FUNCTION with RESULT specifier Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: beliavsky at aol dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31921