[Bug fortran/35743] New: allocate negative memory for zero-sized WHERE construct

dick dot hendrickson at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Mar 28 21:23:00 GMT 2008


The following program fails when rg0025 attempts to allocate a negative
amount of memory under windows XP.  It doesn't abort when the array
subscripts are explicit constants instead of variables.

Dick Hendrickson
      program try_rg0025
! fails on Windows XP
! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139]


      logical lda(5)
      lda = (/ (i/2*2 .ne. I, i=1,5) /)

      call       xx0025(lda,  1,  2,  3,  5,  6, -1, -2)   !works
      call       rg0025(lda,  1,  2,  3,  5,  6, -1, -2)   !fails

      end program

      SUBROUTINE XX0025(LDA,nf1,nf2,nf3,nf5,nf6,mf1,mf2)
      type unseq
            real  r
      end type unseq
      TYPE(UNSEQ) TDA1L(6)
      LOGICAL LDA(NF5)

      TDA1L(1:6)%r = 1.0

      WHERE (LDA(6:3))
        TDA1L(-1:5:-1) = TDA1L(6:2)
      ENDWHERE

      print *, 'end of xx0025'
      END SUBROUTINE

      SUBROUTINE RG0025(LDA,nf1,nf2,nf3,nf5,nf6,mf1,mf2)
      type unseq
            real  r
      end type unseq
      TYPE(UNSEQ) TDA1L(6)
      LOGICAL LDA(NF5)

      TDA1L(1:6)%r = 1.0

      WHERE (LDA(NF6:NF3))
        TDA1L(MF1:NF5:MF1) = TDA1L(NF6:NF2)
      ENDWHERE

      END SUBROUTINE

C:\g_experiments\gfortran>gfortran rg0025.f

C:g_experiments\gfortran>a
 end of xx0025
Fortran runtime error: Attempt to allocate a negative amount of memory.


-- 
           Summary: allocate negative memory for zero-sized WHERE construct
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dick dot hendrickson at gmail dot com


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



More information about the Gcc-bugs mailing list