This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer


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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]