In this is both a fortran and a libfortran problem.
Take the following code and try to run it and you will get an internal error:
module mymod
contains
function mystring ()
character(len=4) :: mystring
write (unit=mystring,fmt='(A)') 'aaaa'
end function mystring
end module mymod
program main
use mymod
write (unit=*,fmt='(A)') mystring()
end program main
--
Summary: Recursive IO functions are not allowed
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19352