This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/15335] runtime error "Attempt to allocate a negative amount of memory"



------- Comment #11 from paul dot richard dot thomas at cea dot fr  2006-03-01 16:30 -------
I believe that this PR should be closed as resolved.  Since p is uninitialized
in the original test case, it can and does produce out of range array
references for lu(comment #6).  The following development of the testcase runs
fine:

  program Driver
    real :: a(4,4)
    call factor
contains
    subroutine Factor
      real :: A(4, 4), B(4), lu(4,4)
      integer:: p(4)=(/1,2,3,4/)
      integer:: I
      I = 1
      do M = 1, 4
          LU(P(I), M) = Reduce (LU(P(I), M), LU(P(I), 1: M - 1), LU(P(1: M -
1), M))
      end do

      return
    end subroutine Factor  
    function Reduce (A, Row, Col)
      real :: A, Row(:), Col(:)
      print *, "size of row=", size(row)
      print *, "size of col=", size(col)
      reduce = 0
    end function Reduce
  end program Driver

producing

$ ./a
 size of row=           0
 size of col=           0
 size of row=           1
 size of col=           1
 size of row=           2
 size of col=           2
 size of row=           3
 size of col=           3

which shows that the programmer must take care of his or her array references!

The question of what to do with negative memory requests is of course tied up
by the confusion with integer overflows as the error message in
memory.c(allocate) says.  PR26017 is an unambiguous case where this error
should not be triggered and will function as a placeholder for this type of
problem. 


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]