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/29489] New: LBOUND (array) and LBOUND (array, DIM) give different results.


In the case of zero sized automatic arrays, LBOUND(array) and LBOUND(array,
DIM) can give different results:

program fred

  call jackal (3, 2)

contains

  subroutine jackal (b, c)
    integer :: b, c
    integer :: soda(b:c, 1:2)

    print *, "SIZE = ", size(soda)
    print *, "LBOUND (soda, DIM) = ", ubound (soda, 1), ubound(soda, 2)
    print *, "LBOUND (soda)      = ", ubound (soda)

  end subroutine jackal
end

gives:

 SIZE =            0
 LBOUND (soda, DIM) =            2           2
 LBOUND (soda)      =            2           0

>From my reading of the standard, it is the second LBOUND which is correct. ie.
the array soda is zero size in that dimension.

I have stared at the code until I am blue in the face but cannot see why there
is this difference in results.  I will attach a patch for trans-instrinsic.c
that fixes the conditions in gfc_conv_intrinsic_bound and the code that it
produces for print *, LBOUND(soda,2) and print *, LBOUND(soda).

Paul


-- 
           Summary: LBOUND (array) and LBOUND (array, DIM) give different
                    results.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pault at gcc dot gnu dot org


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


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