http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52102
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-03 13:37:39 UTC --- Related issue with MOLD=, here one gets with "x = 5" default initialization and allocate (two%a(8), mold=t(4)) print '(*(i2))', two%a(:)%x the result: 0 0 0 0 0 0 0 5 That is: only the last element gets the value. >From the dump: two.a._data.offset = -1; ... struct t t.2; t.2.x = 5; D.1886 = t.2; __vtab_MAIN___T._copy (&D.1886, &(*(struct t[0:] * restrict) two.a._data.data)[two.a._data.offset + 8]); Note the constant offset of "8", which matches the ubound. Note further that the _copy construct is *not* in a scalarizing loop but only called once for the last element. * * * The following looks odd: gfc_trans_allocate (gfc_code * code) { ... if (code->expr3 && !code->expr3->mold) { ... /* Do a polymorphic deep copy. */ ... actual->next->expr = gfc_copy_expr (al->expr); dataref = actual->next->expr->ref; if (dataref->u.c.component->as) The latter makes no sense in this case as the base object is not the class container. We need to access the last component ref on the ref list.