https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63867
Bug ID: 63867
Summary: LEN is lost for a CHARACTER variable inside SELECT
TYPE
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mrestelli at gmail dot com
Consider the following code:
program p
implicit none
character(len=5) :: str
str = 'abcde'
call checklen1(str)
call checklen2(str)
contains
subroutine checklen1(s)
character(len=*), intent(in) :: s
call checklen2(s)
end subroutine checklen1
subroutine checklen2(s)
class(*), intent(in) :: s
select type(s)
type is(character(len=*))
write(*,*) "Len is ",len(s)
write(*,*) "s is ",s
end select
end subroutine checklen2
end program p
When compiled with gfortran it prints
$ ./test
Len is 0
s is
Len is 5
s is abcde
while the expected output is twice the same, i.e.
$ ./test
Len is 5
s is abcde
Len is 5
s is abcde
I.e., inside the SELECT TYPE the lenght of the string is lost, but
only when the actual argument is itself a dummy argument with LEN=* .
$ gfortran --version
GNU Fortran (GCC) 5.0.0 20141114 (experimental)
Marco