This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45489] Default initialization of derived-type function result missing
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Sep 2010 21:05:58 -0000
- Subject: [Bug fortran/45489] Default initialization of derived-type function result missing
- References: <bug-45489-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from burnus at gcc dot gnu dot org 2010-09-01 21:05 -------
See thread at http://gcc.gnu.org/ml/fortran/2010-09/msg00044.html (+
previous/later emails) for the discussion.
Note: The following simple patch does *not* work but gives an ICE:
test.f90:9:0: internal compiler error: in gfc_get_symbol_decl, at
fortran/trans-decl.c:1055
--- resolve.c (Revision 163740)
+++ resolve.c
@@ -12175,27 +12147,33 @@ resolve_symbol (gfc_symbol *sym)
|| sym->ns->proc_name->attr.flavor != FL_MODULE)))
gfc_error ("Threadprivate at %L isn't SAVEd", &sym->declared_at);
/* If we have come this far we can apply default-initializers, as
described in 14.7.5, to those variables that have not already
- been assigned one. */
+ been assigned one. That includes arrays with non-constant bounds
+ and function results. */
if (sym->ts.type == BT_DERIVED
- && sym->attr.referenced
&& sym->ns == gfc_current_ns
&& !sym->value
&& !sym->attr.allocatable
&& !sym->attr.alloc_comp)
{
symbol_attribute *a = &sym->attr;
if ((!a->save && !a->dummy && !a->pointer
&& !a->in_common && !a->use_assoc
+ && (sym->attr.referenced || sym->attr.result)
&& !(a->function && sym != sym->result))
|| (a->dummy && a->intent == INTENT_OUT && !a->pointer))
apply_default_init (sym);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45489