http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45828

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #5 from janus at gcc dot gnu.org 2010-09-30 14:48:17 UTC ---
(In reply to comment #3)
> the problem seems to be in expr.c (called from resolve.c:
> resolve_allocate_expr())
> 
> [...]
> 
> if a derived type has a derived type component it only checks whether
> that components components have default initializers, not the component
> itself.

Right. To fix it I propose the following patch (not regtested yet):

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (revision 164461)
+++ gcc/fortran/expr.c    (working copy)
@@ -3662,21 +3662,18 @@ gfc_has_default_initializer (gfc_symbol *der)

   gcc_assert (der->attr.flavor == FL_DERIVED);
   for (c = der->components; c; c = c->next)
-    if (c->ts.type == BT_DERIVED)
-      {
-        if (!c->attr.pointer
-         && gfc_has_default_initializer (c->ts.u.derived))
-      return true;
-      }
-    else
-      {
-        if (c->initializer)
-      return true;
-      }
+    {
+      if (c->ts.type == BT_DERIVED && !c->attr.pointer
+      && gfc_has_default_initializer (c->ts.u.derived))
+    return true;
+      if (c->initializer)
+    return true;
+    }

   return false;
 }

+
 /* Get an expression for a default initializer.  */

 gfc_expr *

Reply via email to