https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99027
Bug ID: 99027
Summary: Incorrect ubound result
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: andrew.burgess at embecosm dot com
Target Milestone: ---
I believe I have run into a case where ubound is giving the wrong result.
Given:
program test
integer, dimension (1:3,1:6) :: array
print *, "ubound = ", ubound (array (1, 1:4))
end program test
I see the output:
ubound = 1
When I would have expected:
ubound = 4
Due to array (1, 1:4) being a 4 element 1-dimensional array.
I am seeing this behaviour in my default Fedora compiler:
GNU Fortran (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
But I also build current HEAD from git (26a3f288f18) and am still seeing this
issue:
GNU Fortran (GCC) 11.0.0 20210209 (experimental)
Interestingly, if I change the test program to:
program test
integer, dimension (1:3,1:6) :: array
print *, "ubound = ", ubound (array (1:2, 1:4))
end program test
Then I do now see what I would expect for this case:
ubound = 2 4