http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49324
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-14 13:07:07 UTC --- (Comment fixed 8 fixed the missing deep copy.) Regarding the reallocate (cf. comment 6, but using scalars to reduce the dump size): For type t integer, allocatable :: A end type t type(t), allocatable :: z ... z = [ x ] One gets the following dump: /* If not initialized. For arrays: Also realloc, if the size is wrong. */ if (z != 0B) goto L.1; z = (struct t *) __builtin_malloc (8); So far so good, but one then has D.1552 = *z; if (D.1552.a != 0B) __builtin_free ((void *) D.1552.a); which is only OK if "z.data" has neither been just allocated nor reallocated. If it has, there are two problems: (a) The old memory is not freed. (b) if malloc/realloc does not return nullified memory, free() operates on some random pointer. The question is how to handle it best? The assignment is handled in gfc_trans_assignment_1, which calls gfc_alloc_allocatable_for_assignment for the realloc and gfc_trans_scalar_assign for the assignment.