http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45170
--- Comment #18 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-07-15 14:02:45 UTC --- (In reply to comment #16) > Error: Variable 'length' cannot appear in the expression at (1) > That comes from the specification expression check. If one removes the check, it works, i.e. it is just a resolution (resolve.c) problem and not a code generation one. (In reply to comment #17) > subroutine hello (n,string) > character(:),allocatable,intent(out)::string > integer,intent(in)::n > string=helloworld(:n) That one seems to be a very subtle issue, depending on the modifications (e.g. allocate(character(len=)) instead of alloc on assignment), one might get the correct string length - or even the correct string. Looking at the (original) dump, the string length should be always correct, hence, I think we generate a slightly wrong tree. The next step would be to look at -fdump-tree-optimized and then work backwards.