https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83118
--- Comment #17 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 46216 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46216&action=edit Patch for the remaining problems. I am registering this now as a measure of progress towards doing a proper job of fixing this PR for good. The part in trans-expr.c(gfc_trans_assignment_1) is obligatory and stops the compiler doubling up mallocs on top of one another. The part in trans-array.c(gfc_alloc_allocatable_for_assignment) is a partial solution. Instead of testing the shape of the lhs against that of that of the rhs, we need to be comparing the size in bytes. The attached lets the system do this by relying on realloc to do the job. This might be the most efficient way to do it - I will look into it. I note in passing that the estimate of the size of the rhs is going to fail, where class entities are a dynamic type other than the declared type. This is easily done and requires perspiration rather than inspiration :-) Paul