>From a posting to comp.lang.fortran:

program xint_func
  implicit none
  integer, parameter :: n=3,ii(n)=(/2,0,-1/)
  integer            :: i
  character(len=80)  :: line
  do i=1,n
     write (line,'(10I5)'), int_func(ii(i))
  end do
contains
  function int_func(n) result(ivec)
    integer, intent(in) :: n
    integer             :: ivec(n)
    integer             :: i
    if (n > 0) then
       forall (i=1:n) ivec(i) = i
    end if
  end function int_func
end program xint_func
$ gfortran foo.f90
$ ./a.out
Fortran runtime error: Attempt to allocate a negative amount of memory.
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc/trunk/configure --prefix=/home/ig25
--enable-languages=c,fortran
Thread model: posix
gcc version 4.2.0 20060525 (experimental)

I'm looking into this.


-- 
           Summary: Wrong allocation for zero-sized function result
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


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

Reply via email to