https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77649
Bug ID: 77649
Summary: Wrong error reported with bound checking enabled
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mrestelli at gmail dot com
Target Milestone: ---
When compiled with -fcheck=all the following code produces an
incorrect error at runtime:
$ gfortran test.f90 -fcheck=all -o test
$ ./test
At line 13 of file test.f90
Fortran runtime error: Index '2' of dimension 1 of array 'text' above upper
bound of 1
$ gfortran --version
GNU Fortran (GCC) 7.0.0 20160919 (experimental)
program p
implicit none
character(len=10) :: s
s = fs((/"abc","d "/))
write(*,*) s
contains
function fs(text) result(s)
character(len=*), intent(in) :: text(:)
integer :: i
character(len=sum((/(len_trim(text(i)) , i=1,size(text))/))) :: s
write(*,*) "len(s) = ", len(s)
s = "XYZ"
end function fs
end program p