http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49802
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |20585 Summary|[F2008] Handle VALUE with |[F2003, F2008] Wrong code |arrays (DIMENSION) |with VALUE, F2008: VALUE | |with arrays/DIMENSION --- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-07-21 10:13:33 UTC --- As postscript: Using strings works - but only as long as the length is known at compile time (as F2003 mandates). If not, the dump looks OK at a glance but it does not work: CALLER: by_value (str, 10); CALLEE: by_value (character(kind=1)[1:_y] y, integer(kind=4) _y) D.1554 = _y; _gfortran_transfer_integer_write (&dt_parm.0, &D.1554, 4); but the latter does not print the expected "10" but some seemingly random number. Obviously, passing strings by value fails if the length is not known - one should thus go back to pass them by reference after copying. Test case: Change "(*)" to "(10)" for a working program: implicit none character(len=10) :: str str = "123456789" call by_value(str) print *, str if (str /= "123456789") call abort() contains subroutine by_value(y) character(len=*), value :: y print *, len(y) if (len(y) /= 10) call abort() print *, y y = "abcdefghij" print *, y if (str /= "abcdefghij") call abort() end subroutine end