------- Comment #2 from pault at gcc dot gnu dot org 2006-10-10 09:50 ------- FX,
There are two problems here; one is specific to LEN and the other is generic to intrinsics and array valued actual arguments: The LEN specific problem is that there is no need to call the function at all, in the particular case concerned. I did a simple modification to gfc_resolve_len, in which I copied the character-length expression from the actual argument to the the result, f. It worked fine; I do not have it here, so will post it on Thursday, when i am back at work. The generic problem is that of the conversion of array valued args., when there is no loop. The giveaway is that this works: PRINT *, PLEN(SUB(3)) CONTAINS FUNCTION SUB(I) CHARACTER(LEN=I) :: SUB(1) END FUNCTION integer function plen(arg) character(*) :: arg (:) plen = len (arg) end function plen END The difference is the way in which array arguments are handled. The intrinsics go straight for gfc_conv_expr_descriptor with nothing prepared. In consequence, the function is called with the observed consequences. What is needed is to build an ss and call gfc_conv_array_parameter, so that the function is called with loop and info built and a temporary presented to the intrinsic. I'll play with it this afternoon. Paul -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29387