The following program gives wrong results for some positions in LBOUND and UBOUND. The allocated array has a run-time computed zero-sized subscript range in the 4th subscript. LBOUND and UBOUND give incorrect results for the 5th, 6th, and 7th subscript. They propagate the zero size (1,0) pair. the results in subscripts 1, 2, and 3 are correct.
The results are correct if the 4th subscript is replaced with 10:1 instead of the run-time expression. Dick Hendrickson first test loop 5 expected lbound = -2 computed = 1 6 expected lbound = -3 computed = 1 7 expected lbound = -4 computed = 1 second test loop 5 expected ubound = 7 computed = 0 6 expected ubound = 8 computed = 0 7 expected ubound = 9 computed = 0 program try_lf0030 ! fails on Windows XP ! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139] call LF0030(10) end SUBROUTINE LF0030(nf10) INTEGER ILA1(7) INTEGER ILA2(7) LOGICAL LLA(:,:,:,:,:,:,:) INTEGER ICA(7) ALLOCATABLE LLA ALLOCATE (LLA(2:3, 4, 0:5, $ NF10:1, -2:7, -3:8, $ -4:9)) ILA1 = LBOUND(LLA) ILA2 = UBOUND(LLA) C CORRECT FOR THE ZERO DIMENSIONED TERM TO ALLOW AN EASIER VERIFY ILA1(4) = ILA1(4) - 2 ! 1 - 2 = -1 ILA2(4) = ILA2(4) + 6 ! 0 + 6 = 6 print *, 'first test loop' DO J1 = 1,7 IVAL = 3-J1 IF (ILA1(J1) .NE. IVAL) print *, J1, " expected lbound =", $ ival, "computed = ", ila1(j1) 100 ENDDO print *, 'second test loop' DO J1 = 1,7 IVAL = 2+J1 IF (ILA2(J1) .NE. IVAL) print *, J1, " expected ubound =", $ ival, "computed = ", ila2(j1) 101 ENDDO END SUBROUTINE -- Summary: lbound and ubound wrong for allocated run-time zero size array 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=35698