So the reproducer program has no problem accept it does not produce what you expect in the debugger, or is the reproducer failing in some way? Because you were using the debugger and saw the type not returning you may have identified a bug in the debugger/compiler interface and
not the cause of your program bug if that is the case.
I see nothing wrong with the reproducer myself. It has a few oddities but given the age and that it is a reduced example that is understandable.
But if the example program itself is not working I could not reproduce a problem with it. So what compiler options are you using? I would recommend putting the AHO() function in a module or making it a contained procedure.
I would recommend adding an EXTERNAL statement to see if that has any effect. It makes it clearer AHO is a procedure without an explicit interface as well.
At the moment I do not have gdb available but I will later but in the meantime does this
replacement for the main program print the expected results, and if you make AHO() a contained
procedure does anything improve?
program defchararr
use arraymod, only : aloc_arr, chararr
implicit none
character*6 aho
external aho
call aloc_arr(3)
chararr(1,1)=aho()
print *, chararr(1,1)
call whatami(chararr(1,1))
call whatami(aho())
contains
subroutine whatami(a)
class(*),intent(in) :: a
select type ( a )
type is ( integer )
write(*,'(*(g0:,1x))')'type is integer, kind=',kind(a)
type is ( character(len=*) )
write(*,'(*(g0:,1x))')'type is character, len=',len(a)
class default
write(*,'(*(g0:,1x))')'sorry, I do not know your type'
end select
end subroutine whatami
end program defchararr
Expected
ahoaho
type is character, len= 6
type is character, len= 6