public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer
@ 2012-01-09 18:23 mario-baumann at web dot de
  2012-01-09 18:35 ` [Bug fortran/51800] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mario-baumann at web dot de @ 2012-01-09 18:23 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51800
           Summary: Error: Automatic array 'dummy' at (1) cannot have an
                    initializer
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mario-baumann@web.de


Created attachment 26282
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26282
fortran90 source file

Hi Gfortran Team,

compilation of the attached source file failed if using the both compiler
options -fno-automatic and -finit-local-zero.

> gfortran -c -m32 -O0 -fno-automatic -finit-local-zero foo.f90
foo.f90:6.27:
      INTEGER :: DUMMY(1:N)
                           1
Error: Automatic array 'dummy' at (1) cannot have an initializer

It works fine if removing at least one of the both options above.

-------------------------------------------------------------------------------

> uname -a
Linux ahsoka.intec.dom 2.6.32-220.2.1.el6.x86_64 #1 SMP Tue Dec 13 16:21:34 EST
2011 x86_64 x86_64 x86_64 GNU/Linux

> rpm -qa "glibc*" | grep -e 'glibc-[0-9]' | sort -u
glibc-2.12-1.47.el6.i686
glibc-2.12-1.47.el6.x86_64

> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/app2/gcc/4.7.0-20120109-svn183001/i686/libexec/gcc/i686-unknown-linux-gnu/4.7.0/lto-wrapper
Target: i686-unknown-linux-gnu
Configured with: ./configure --prefix=/app2/gcc/4.7.0-20120109-svn183001/i686
--enable-languages=c,c++,fortran --disable-nls
--with-gmp=/app2/gcc/4.7.0-20120109-svn183001/i686/aux
--with-mpfr=/app2/gcc/4.7.0-20120109-svn183001/i686/aux
--with-mpc=/app2/gcc/4.7.0-20120109-svn183001/i686/aux
--with-ppl=/app2/gcc/4.7.0-20120109-svn183001/i686/aux
--with-cloog=/app2/gcc/4.7.0-20120109-svn183001/i686/aux --disable-multilib
--build=i686-unknown-linux-gnu
Thread model: posix
gcc version 4.7.0 20120109 (experimental) (GCC) 

> ld -v
GNU ld (GNU Binutils) 2.22.51.20120109


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
@ 2012-01-09 18:35 ` burnus at gcc dot gnu.org
  2012-01-09 23:40 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-09 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |toon at moene dot org
      Known to work|                            |4.6.2
   Target Milestone|---                         |4.6.3
            Summary|Error: Automatic array      |[4.6/4.7 Regression] Error:
                   |'dummy' at (1) cannot have  |Automatic array 'dummy' at
                   |an initializer              |(1) cannot have an
                   |                            |initializer
      Known to fail|                            |4.7.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-09 18:34:52 UTC ---
I think that's due to the patch for PR 51310, i.e. the patches:
 [4.7]  http://gcc.gnu.org/ml/fortran/2011-12/msg00080.html
 [4.6]  http://gcc.gnu.org/ml/fortran/2011-12/msg00119.html

Toon, can you have a look?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
  2012-01-09 18:35 ` [Bug fortran/51800] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
@ 2012-01-09 23:40 ` jakub at gcc dot gnu.org
  2012-01-11 15:04 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-09 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
  2012-01-09 18:35 ` [Bug fortran/51800] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
  2012-01-09 23:40 ` jakub at gcc dot gnu.org
@ 2012-01-11 15:04 ` burnus at gcc dot gnu.org
  2012-01-11 16:07 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-11 15:04 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
                   ` (2 preceding siblings ...)
  2012-01-11 15:04 ` burnus at gcc dot gnu.org
@ 2012-01-11 16:07 ` burnus at gcc dot gnu.org
  2012-01-14 12:28 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-11 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-11 16:06:26 UTC ---
(In reply to comment #2)
> There is an additional issue for initialization of characters:
>   subroutine sub(n)
>     character(len=n) :: str

That was simpler that I had hoped for:

subroutine foo(n)
  character(len=n) :: str
  print *, str
end subroutine foo

call foo(3)
call foo(10)
end

$ gfortran -finit-character=89 test.f90 && ./a.out
 YYY
 YYYYYYYYYY


--- resolve.c   (revision 183093)
+++ resolve.c   (working copy)
@@ -10143,6 +10143,26 @@ build_default_init_expr (gfc_symbol *sym)
          gfc_free_expr (init_expr);
          init_expr = NULL;
        }
+      if (!init_expr && gfc_option.flag_init_character ==
GFC_INIT_CHARACTER_ON
+         && sym->ts.u.cl->length)
+       {
+         gfc_actual_arglist *arg;
+         init_expr = gfc_get_expr ();
+         init_expr->where = sym->declared_at;
+         init_expr->ts = sym->ts;
+         init_expr->expr_type = EXPR_FUNCTION;
+         init_expr->value.function.isym =
+               gfc_intrinsic_function_by_id (GFC_ISYM_REPEAT);
+         init_expr->value.function.name = "repeat";
+         arg = gfc_get_actual_arglist ();
+         arg->expr = gfc_get_character_expr (sym->ts.kind, &sym->declared_at,
+                                             NULL, 1);
+         arg->expr->value.character.string[0]
+               = gfc_option.flag_init_character_value;
+         arg->next = gfc_get_actual_arglist ();
+         arg->next->expr = gfc_copy_expr (sym->ts.u.cl->length);
+         init_expr->value.function.actual = arg;
+       }
       break;

     default:


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
                   ` (3 preceding siblings ...)
  2012-01-11 16:07 ` burnus at gcc dot gnu.org
@ 2012-01-14 12:28 ` burnus at gcc dot gnu.org
  2012-01-14 14:20 ` burnus at gcc dot gnu.org
  2012-01-14 15:44 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-14 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-14 12:06:04 UTC ---
Author: burnus
Date: Sat Jan 14 12:05:59 2012
New Revision: 183180

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183180
Log:
2012-01-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51800
        * resolve.c (build_default_init_expr): Also initialize
        nonconstant-length strings with -finit-character=<n>.

2012-01-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51800
        * gfortran.dg/init_flag_8.f90: New.
        * gfortran.dg/init_flag_9.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/init_flag_8.f90
    trunk/gcc/testsuite/gfortran.dg/init_flag_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
                   ` (4 preceding siblings ...)
  2012-01-14 12:28 ` burnus at gcc dot gnu.org
@ 2012-01-14 14:20 ` burnus at gcc dot gnu.org
  2012-01-14 15:44 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-14 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-14 13:28:10 UTC ---
Author: burnus
Date: Sat Jan 14 13:28:05 2012
New Revision: 183181

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183181
Log:
2012-01-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51800
        * resolve.c (build_default_init_expr): Also initialize
        nonconstant-length strings with -finit-character=<n>.

2012-01-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51800
        * gfortran.dg/init_flag_8.f90: New.
        * gfortran.dg/init_flag_9.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/init_flag_8.f90
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/init_flag_9.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/resolve.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/51800] [4.6/4.7 Regression] Error: Automatic array 'dummy' at (1) cannot have an initializer
  2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
                   ` (5 preceding siblings ...)
  2012-01-14 14:20 ` burnus at gcc dot gnu.org
@ 2012-01-14 15:44 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-14 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-14 13:28:58 UTC ---
FIXED on the trunk (4.7) and on the 4.6 branch.

Thanks Mario for the report!


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-14 13:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09 18:23 [Bug fortran/51800] New: Error: Automatic array 'dummy' at (1) cannot have an initializer mario-baumann at web dot de
2012-01-09 18:35 ` [Bug fortran/51800] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
2012-01-09 23:40 ` jakub at gcc dot gnu.org
2012-01-11 15:04 ` burnus at gcc dot gnu.org
2012-01-11 16:07 ` burnus at gcc dot gnu.org
2012-01-14 12:28 ` burnus at gcc dot gnu.org
2012-01-14 14:20 ` burnus at gcc dot gnu.org
2012-01-14 15:44 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).