http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56138
--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-02-02 12:21:28 UTC --- > Paul's patch fixes the issue (similarly to my original patch, which, however, > regressed). Confirmed. > As Paul's patch doesn't regress: OK with reverting my patch and changing the > test case to a noncontained procedure (plus interface block in the caller). With the patch the following test compiles and runs: ! { dg-do run } ! ! PR fortran/56138 ! ! Contributed by John Chludzinski, using the code of John Reid ! implicit none interface PURE FUNCTION s_to_c(string) CHARACTER(LEN=*),INTENT(IN) :: string CHARACTER(LEN=:),ALLOCATABLE :: s_to_c ENDFUNCTION s_to_c end interface CHARACTER(LEN=:),ALLOCATABLE :: str if (s_to_c("ABCdef") /= "ABCdef" .or. len(s_to_c("ABCdef")) /= 6) call abort() str = s_to_c("ABCdef") if (str /= "ABCdef" .or. len(str) /= 6) call abort() str(1:3) = s_to_c("123") if (str /= "123def" .or. len(str) /= 6) call abort() end PURE FUNCTION s_to_c(string) CHARACTER(LEN=*),INTENT(IN) :: string CHARACTER(LEN=:),ALLOCATABLE :: s_to_c s_to_c = string ENDFUNCTION s_to_c In addition the first test in pr54070 comment #0 compiles, while the two others still give an ICE at gimplify.c:2082. AFAICT the critical difference between these tests and the ones in this PR is that the former have an assumed shape for the allocatable result.