This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 11 Jan 2012 15:03:42 +0000
- Subject: [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
- Auto-submitted: auto-generated
- References: <bug-51800-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51800
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-11 15:03:42 UTC ---
Draft patch.
There is an additional issue for initialization of characters:
subroutine sub(n)
character(len=n) :: str
except that no initializer seems to be applied if the string length
is not known at compile time - otherwise, one had to handle it below
as well.
Index: resolve.c
===================================================================
--- resolve.c (revision 183093)
+++ resolve.c (working copy)
@@ -10172,7 +10172,8 @@ apply_default_init_local (gfc_symbol *sym)
/* For saved variables, we don't want to add an initializer at
function entry, so we just add a static initializer. */
if (sym->attr.save || sym->ns->save_all
- || gfc_option.flag_max_stack_var_size == 0)
+ || (gfc_option.flag_max_stack_var_size == 0
+ && (!sym->attr.dimension || !is_non_constant_shape_array (sym))))
{
/* Don't clobber an existing initializer! */
gcc_assert (sym->value == NULL);