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/38852] New: UBOUND fails for negative stride triplets


The UBOUND function returns zero for subscript triplets that have a negative
stride, such as 5:4:-1.  Fails with both compile-time expressions and run-time
expressions.  LBOUND and SHAPE work correctly on the same triplets.

This might be related to 35685 since I think this started soon after 35685 was
closed.

Dick Hendrickson


      program try_je0031

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

      integer ida(4)
      real dda(5,5,5,5,5)
      call JE0031(IDA,DDA,2,5,-2)

      end 

      SUBROUTINE JE0031(IDA,DDA,nf2,nf5,mf2)
      INTEGER IDA(4)
      REAL DLA(:,:,:,:)
      REAL DDA(5,5,5,5,5)
      POINTER DLA
      TARGET DDA

      DLA => DDA(2:3, 1:3:2, 5:4:-1, NF2, NF5:NF2:MF2)
      IDA = UBOUND(DLA)
      if (any(ida /= 2)) print *, '    run-time ubound', ida

      DLA => DDA(2:3, 1:3:2, 5:4:-1, 2, 5:2:-2)
      IDA = UBOUND(DLA)
      if (any(ida /= 2)) print *, 'compile-time ubound', ida

!these work
      DLA => DDA(2:3, 1:3:2, 5:4:-1, 2, 5:2:-2)
      IDA = shape(DLA)
      if (any(ida /= 2)) print *, ' compile-time shape', ida

      DLA => DDA(2:3, 1:3:2, 5:4:-1, 2, 5:2:-2)
      IDA = LBOUND(DLA)
      if (any(ida /= 1)) print *, 'compile-time lbound', ida

      END SUBROUTINE


C:\gfortran>gfortran try_je0031.f

C:\gfortran>a
     run-time ubound           2           2           0           0
 compile-time ubound           2           2           0           0


-- 
           Summary: UBOUND fails for negative stride triplets
           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=38852


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