------- Comment #2 from jvdelisle at gcc dot gnu dot org  2008-01-20 02:56 
-------
Here is a reduced case that illustrates the problem.  Not specifying the
negative stride in either the read or write results in a failure. See the
commented lines.

      program qi0011
      character(9) bda(10)
      character(9) bda1(10)
      integer  j_len
      istat = -314

      inquire(iolength = j_len) bda1

      print '("j_len=",i2)',j_len

      istat = -314
      open (unit=48,
     $      access='direct',
     $      recl = j_len,
     $      status="scratch",
     $      iostat = istat,
     $      form='unformatted',
     $      action='readwrite')

      bda = 'xxxxxxxxx'
      bda1 ='123456789'
      write (48, rec = 10) bda1(4:3:-1)! This works
c      write (48, rec = 10) bda1(4:3)              ! This fails
      read (48, rec=10) bda(7:6:-1)    ! This works
c      read (48, rec=10) bda(7:6)                  ! This fails
      print '(10(a))', bda1
      print '(10(a))', bda
      end

Looking at -fdump-tree-original:

With stride given:
    {
      struct array1_unknown parm.9;

      parm.9.dtype = 625;
      parm.9.dim[0].lbound = 1;
      parm.9.dim[0].ubound = 2;
      parm.9.dim[0].stride = -1;
      parm.9.data = (void *) (character(kind=1)[0:][1:9] *) &bda1[3];
      parm.9.offset = 0;
      _gfortran_transfer_array (&dt_parm.8, &parm.9, 1, 9);
    }

Without stride given:
    {
      struct array1_unknown parm.9;

      parm.9.dtype = 625;
      parm.9.dim[0].lbound = 1;
      parm.9.dim[0].ubound = 0;
      parm.9.dim[0].stride = 1;
      parm.9.data = (void *) (character(kind=1)[0:][1:9] *) &bda1[3];
      parm.9.offset = -4;
      _gfortran_transfer_array (&dt_parm.8, &parm.9, 1, 9);
    }


-- 


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

Reply via email to