Perhaps I have been up too long myself. I thought the RESULT() syntax was
added specifically to allow unambigious recursion and would be the answer
as if bug5() took no parameters what would "//bug5" mean, as () is often optional,
or it it took an integer argument but returned an integer array is bug5(3) a reference
to an element or a recursive call to the procedure, and so on. I would have used RESULT(ANSWER)
on any recursive procedure ( I actually see no recursion here, by the way (?) ; but perhaps that is
just an old habit because of bugs I hit in the past as I was surprised it was required. Although I was
really surprised that recursive was becoming the default and wondered why that did not break a lot
things. Anyway, interesting. Some old assumptions I had are apparently wrong; bug using RESULT(ANSWER)
gfortran quit complaining. Gives me a few things to look back up and reread.
recursive function bug5(x) result(answer)
implicit none
character(*), intent(in) :: x
character(:), allocatable :: answer
answer = x
if(answer(1:1) == 'Z') answer = '_'//answer
end function bug5
recursive program test
interface
function bug5(x)
character(*), intent(in) :: x
character(:), allocatable :: bug5
end function bug5
end interface
write(*,*)bug5("Arthur")
write(*,*)bug5("Zaphod")
end program test
Maybe a gfortran bug is what made me form that habit.