http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45828
--- Comment #6 from janus at gcc dot gnu.org 2010-09-30 19:23:11 UTC --- (In reply to comment #5) > To fix it I propose the following patch (not regtested yet): Regtesting showed that the patch in comment #5 fails on common_10.f90 (due to the fact that the 'initializer' field may be set also for components without default initialization). Here is a better patch, which avoids the use of 'gfc_has_default_initializer': Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 164755) +++ gcc/fortran/resolve.c (working copy) @@ -6708,6 +6708,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code { /* Set up default initializer if needed. */ gfc_typespec ts; + gfc_expr *init_e; if (code->ext.alloc.ts.type == BT_DERIVED) ts = code->ext.alloc.ts; @@ -6717,9 +6718,8 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code if (ts.type == BT_CLASS) ts = ts.u.derived->components->ts; - if (ts.type == BT_DERIVED && gfc_has_default_initializer(ts.u.derived)) + if (ts.type == BT_DERIVED && (init_e = gfc_default_initializer (&ts))) { - gfc_expr *init_e = gfc_default_initializer (&ts); gfc_code *init_st = gfc_get_code (); init_st->loc = code->loc; init_st->op = EXEC_INIT_ASSIGN;