[Bug fortran/98454] Apparent wrong initialization in function result
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 28 15:19:49 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98454
--- Comment #11 from anlauf at gcc dot gnu.org ---
The following hack fixes the testcase in comment#10,
but not the testcase in comment#2:
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 249f402b8d9..2c9570d4641 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16046,6 +16046,9 @@ resolve_symbol (gfc_symbol *sym)
/* Mark the result symbol to be referenced, when it has allocatable
components. */
sym->result->attr.referenced = 1;
+
+ if (a->function && sym->result && sym->result->attr.referenced)
+ apply_default_init (sym);
}
if (sym->ts.type == BT_CLASS && sym->ns == gfc_current_ns
The logic in resolve_symbol checking for the necessity of
default initialization is hard to parse. Could need some guidance...
More information about the Gcc-bugs
mailing list