[Bug fortran/18899] New: gfortran/libfortran(?): ubound wrongly calculated for passed array

anlauf at hep dot tu-darmstadt dot de gcc-bugzilla@gcc.gnu.org
Thu Dec 9 08:50:00 GMT 2004


Hi,

the following code snippet shows that gfortran calculates
the upper bound wrong when the lower bound is not 1.
(If this a bug in libfortran, please adjust the subject.)

module gfcbug22
  implicit none
contains
  subroutine foo (a)
    integer :: a(0:)
    if (lbound (a, dim=1) /= 0 .or. ubound (a, dim=1) /= 1) then
       print *, "Fail!"
       print '(1x,a,i2,a,i2)', &
            "lbound =", lbound (a, dim=1), ", ubound =", ubound (a, dim=1)
    end if
  end subroutine foo
end module gfcbug22

program gfctest22
  use gfcbug22
  implicit none
  integer :: a(0:1)
! It is apparently ok here...
!  print '(1x,a,i2,a,i2)', &
!       "lbound =", lbound (a, dim=1), ", ubound =", ubound (a, dim=1)
  call foo (a)
end program gfctest22

Compiling & running, I get:

 Fail!
 lbound = 0, ubound = 2

Cheers,
-ha

-- 
           Summary: gfortran/libfortran(?): ubound wrongly calculated for
                    passed array
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at hep dot tu-darmstadt dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-cygwin


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



More information about the Gcc-bugs mailing list