http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47674
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-03 07:23:18 UTC --- The problem seems to be that for strings, the dependency resolver does not trigger: as there are no strides, certain dependencies are already handled, but it fails if the LHS/RHS variables are the same and LHS is reallocated because of a different (shorter) string length. dependency.c's gfc_dep_resolver has: case REF_SUBSTRING: /* Substring overlaps are handled by the string assignment code if there is not an underlying dependency. */ return (fin_dep == GFC_DEP_OVERLAP) ? 1 : 0; which returns 0 for: string = string(1:2) ! Issue: Realloc without temporary trans-expr.c's alloc_scalar_allocatable_for_assignment handles scalars, where the value might bet wrong. A similar issue exists for arrays, though here there are provisions for adding temporaries. (Cf. also trans-array.c's gfc_alloc_allocatable_for_assignment.) I am not quite sure whether which if any part should be handled in the depenedency analysis and which in the assignment code. At least the scalar assignment code does not seem provide for temporaries at all. A related issue is PR 49954: ICE with concatenated array strings.