This is the mail archive of the gcc-patches@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]

[patch,libfortran] PR30145 write statement fails to ignore zero-sized array


:ADDPATCH fortran:

The included patch is trivial and fixes this PR.

Regression tested on x86-64-linux.

I will commit as obvious and simple later today.

Jerry

2006-12-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libfortran/30145
	* io/transfer.c (transfer_array):  Check for negative extent.

Index: transfer.c
===================================================================
*** transfer.c  (revision 119881)
--- transfer.c  (working copy)
*************** transfer_array (st_parameter_dt *dtp, gf
*** 1478,1484 ****

        /* If the extent of even one dimension is zero, then the entire
         array section contains zero elements, so we return.  */
!       if (extent[n] == 0)
        return;
      }

--- 1478,1484 ----

        /* If the extent of even one dimension is zero, then the entire
         array section contains zero elements, so we return.  */
!       if (extent[n] <= 0)
        return;
      }

! { dg-do run }
! PR30145 write statement fails to ignore zero-sized array
! Test case from PR, submitted by Jerry DeLisle  <jvdelisle@gcc.gnu.org>
program zeros
 implicit none
 character(20) :: msg = ""
 integer :: itemp(10) = 0
 integer :: ics
 !This was OK
 write(msg,*) 'itemp(6:0) = ',itemp(6:0),'a'
 if (msg /= " itemp(6:0) = a") call abort()
 !This did not work before patch, segfaulted
 ics=6
 write(msg,*) 'itemp(ics:0) = ',itemp(ics:0),'a'
 if (msg /= " itemp(ics:0) = a") call abort()
end program zeros


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