https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86248
Bug ID: 86248 Summary: LEN_TRIM in specification expression causes link failure Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: longb at cray dot com Target Milestone: --- > cat modu6.f90 module test_module implicit none public :: func_1 integer :: string_length = 3 character(len=*),parameter :: fixed_string = "el_" character(len=3),dimension(0:2),parameter :: darray_fixed = (/"el0","el1","el2"/) character(len=*),dimension(0:2),parameter :: darray = (/"el0","el1","el2"/) contains function func_1(func_1_input) !Declaration section integer, intent(in) :: func_1_input !Test6 character(len=len_trim(darray_fixed(func_1_input))) :: func_1 func_1=darray(func_1_input) end function func_1 end module test_module > cat test.f90 program test use test_module implicit none write(*,*) "Accessing Element index : ",0,"inside value : ",func_1(0) write(*,*) "Accessing Element index : ",1,"inside value : ",func_1(1) write(*,*) "Accessing Element index : ",2,"inside value : ",func_1(2) end program test > diff modu6.f90 modu8.f90 15c15 < character(len=len_trim(darray_fixed(func_1_input))) :: func_1 --- > character(len=len(darray_fixed(func_1_input))) :: func_1 > Using LEN in specification works as expected: > gfortran -c modu8.f90 > gfortran test.f90 modu8.o > ./a.out Accessing Element index : 0 inside value : el0 Accessing Element index : 1 inside value : el1 Accessing Element index : 2 inside value : el2 Using LEN_TRIM instead of LEN fails: > gfortran -c modu6.f90 > gfortran test.f90 modu6.o /lus/scratch/tmp/ccljHL3g.o: In function `MAIN__': test.f90:(.text+0xaf): undefined reference to `__test_PROC_darray_fixed' test.f90:(.text+0x212): undefined reference to `__test_PROC_darray_fixed' test.f90:(.text+0x375): undefined reference to `__test_PROC_darray_fixed' collect2: error: ld returned 1 exit status