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
Confirmed on all releases I have (4.5.0+).