Bug 41515 - [4.3/4.4/4.5 Regression] PARAMETER statement in module subroutines
Summary: [4.3/4.4/4.5 Regression] PARAMETER statement in module subroutines
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P4 normal
Target Milestone: 4.3.6
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 41520 (view as bug list)
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-09-30 08:33 UTC by ros
Modified: 2009-10-02 11:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.2.1
Known to fail: 4.3.4 4.4.1 4.5.0
Last reconfirmed: 2009-09-30 14:38:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ros 2009-09-30 08:33:32 UTC
Using the PARAMETER statement in a module subroutine for assigning values to a character array yields nonsense when printed at runtime.  If, instead, the PARAMETER attribute is used, everything is fine.

gfortran -v yields:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/jerry/gcc/trunk/configure --prefix=/usr/local/gfortran --enable-languages=c,fortran --disable-libmudflap --enable-libgomp --disable-shared
Thread model: posix
gcc version 4.5.0 20090922 (experimental) [trunk revision 151967] (GCC)

uname -a yields:
Linux ros-nb 2.6.25.20-0.5-pae #1 SMP 2009-08-14 01:48:11 +0200 i686 i686 i386 GNU/Linux

The following shows the test program:

Module BUG3
!
contains
!
    Subroutine SR
!
    character(3)   :: parm(5)
!
    parameter(parm=(/'xo ','yo ','ag ','xr ','yr '/))
    write(*,*) parm
!
    end subroutine SR
!
end Module BUG3
!
program TEST

    use bug3
!
    call sr
!
end program TEST
Comment 1 Dominique d'Humieres 2009-09-30 08:52:19 UTC
Confirmed. Works with gfortran 4.2.4, but not with 4.3.4, 4.4.1, and trunk, hence a regression.

As noted,
    character(3), parameter   :: parm(5) = (/'xo ','yo ','ag ','xr ','yr '/)
works.
Comment 2 Tobias Burnus 2009-09-30 14:38:58 UTC
(In reply to comment #1)
> As noted,
>     character(3), parameter   :: parm(5) = (/'xo ','yo ','ag ','xr ','yr '/)
> works.

Interestingly, it also works if one places "parm" into PROGRAM instead of using it in a subroutine (module or separate). In the SUBROUTINE one has (-fdump-tree-original):

  character(kind=1) parm[5][1:3];
      parm.1.data = (void *) &parm[0];

In PROGRAM - or with 4.2 in SUBROUTINE - one has:

  static character(kind=1) parm[5][1:3] = {"xo ", "yo ", "ag ", "xr ", "yr "};
      parm.1.data = (void *) &parm[0];
Comment 3 kargls 2009-09-30 17:06:35 UTC
*** Bug 41520 has been marked as a duplicate of this bug. ***
Comment 4 Tobias Burnus 2009-10-01 16:06:10 UTC
Subject: Bug 41515

Author: burnus
Date: Thu Oct  1 16:05:48 2009
New Revision: 152377

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

        PR fortran/41515
        * decl.c (do_parm): Call add_init_expr_to_sym.

2009-10-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41515
        * gfortran.dg/parameter_array_init_5.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/parameter_array_init_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Tobias Burnus 2009-10-01 16:09:27 UTC
Subject: Bug 41515

Author: burnus
Date: Thu Oct  1 16:09:13 2009
New Revision: 152378

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

        PR fortran/41515
        * decl.c (do_parm): Call add_init_expr_to_sym.

2009-10-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41515
        * gfortran.dg/parameter_array_init_5.f90: New test.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/parameter_array_init_5.f90
Modified:
    branches/gcc-4_4-branch/gcc/fortran/ChangeLog
    branches/gcc-4_4-branch/gcc/fortran/decl.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 6 Tobias Burnus 2009-10-01 16:11:02 UTC
Subject: Bug 41515

Author: burnus
Date: Thu Oct  1 16:10:49 2009
New Revision: 152379

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

        PR fortran/41515
        * decl.c (do_parm): Call add_init_expr_to_sym.

2009-10-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41515
        * gfortran.dg/parameter_array_init_5.f90: New test.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/parameter_array_init_5.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/decl.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 7 Tobias Burnus 2009-10-01 16:12:08 UTC
FIXED for GCC 4.5 (trunk), 4.4 and 4.3.

Thanks for the bugreport!
Comment 8 ros 2009-10-02 09:43:18 UTC
Subject: Re:  [4.3/4.4/4.5 Regression] PARAMETER statement
 in module subroutines

Thanks for fixing the bug 41515.  Where can I find a Linux binary
of gfortran revision 152379, and how can I find out the revision
number without downloading and installing a gfortran binary?


+----------------------------------------------------------------------+
|  Roland Schilling                      Home-Office: +49(89)32929-670 |
|  Max-Planck-Institut für Gravitationsphysik                          |
|  -- Albert-Einstein-Institut --                                      |
|  D-85748 Garching                           E-mail:   ros@rzg.mpg.de |
|  Germany                                  http://www.aei-hannover.de |
+----------------------------------------------------------------------+
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Comment 9 Mikael Morin 2009-10-02 10:17:38 UTC
(In reply to comment #8)
> Where can I find a Linux binary
> of gfortran revision 152379, and how can I find out the revision
> number without downloading and installing a gfortran binary?

See the gfortran wiki
http://gcc.gnu.org/wiki/GFortran
Comment 10 ros 2009-10-02 10:25:45 UTC
Subject: Re:  [4.3/4.4/4.5 Regression] PARAMETER statement
 in module subroutines

On Fri, 2 Oct 2009, mikael at gcc dot gnu dot org wrote:

> ------- Comment #9 from mikael at gcc dot gnu dot org  2009-10-02 10:17 -------
> (In reply to comment #8)
>> Where can I find a Linux binary
>> of gfortran revision 152379, and how can I find out the revision
>> number without downloading and installing a gfortran binary?
>
> See the gfortran wiki
> http://gcc.gnu.org/wiki/GFortran

That's where I looked all the time, but this does not tell me
the revision number :-(


+----------------------------------------------------------------------+
|  Roland Schilling                      Home-Office: +49(89)32929-670 |
|  Max-Planck-Institut für Gravitationsphysik                          |
|  -- Albert-Einstein-Institut --                                      |
|  D-85748 Garching                           E-mail:   ros@rzg.mpg.de |
|  Germany                                  http://www.aei-hannover.de |
+----------------------------------------------------------------------+
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Comment 11 Tobias Burnus 2009-10-02 11:58:07 UTC
(In reply to comment #8)
> Thanks for fixing the bug 41515.  Where can I find a Linux binary
> of gfortran revision 152379, and how can I find out the revision
> number without downloading and installing a gfortran binary?

Depends where you download the binary from. For my x86-64 builds, one can find it in the file name (click on "Download page." or go directly to http://users.physik.fu-berlin.de/~tburnus/gcc-trunk/ )

Otherwise, looking at the file modification date is usually a good indication. Example for the i386-linux build on http://gcc.gnu.org/wiki/GFortranBinaries

$ curl -I http://quatramaran.ens.fr/~coudert/gfortran/gfortran-4.5-linux-i686.tar.gz
[...]
Last-Modified: Thu, 01 Oct 2009 20:21:58 GMT

It also depends on the packager whether (s)he has only the latest 4.5-experimental "trunk" packages or also 4.4- and 4.3-branch builds - or whether the build also includes C++ or has Graphite and/or MPC enabled. (I have both, 4.4 and 4.3, with MPC and Graphite enabled for x86-64-linux; disadvantage of those x86-64-linux builds is that one needs recent enough GLIBC and binutils.)

If you have a recent enough GMP and MPFR, building GCC is also not difficult, cf. bottom of http://gcc.gnu.org/wiki/GFortranBinaries).
Comment 12 ros 2009-10-02 12:35:18 UTC
Subject: Re:  [4.3/4.4/4.5 Regression] PARAMETER statement
 in module subroutines

On Fri, 2 Oct 2009, burnus at gcc dot gnu dot org wrote:

> Depends where you download the binary from. For my x86-64 builds, one can find
> it in the file name (click on "Download page." or go directly to
> http://users.physik.fu-berlin.de/~tburnus/gcc-trunk/ )

Thanks, but unfortunately I need a 32-bit version.

> Otherwise, looking at the file modification date is usually a good indication.
> Example for the i386-linux build on http://gcc.gnu.org/wiki/GFortranBinaries

The point is that in the section 'GNU/Linux' there is no date at all!
I think, it would be a good idea to add there the modification date
and the revision  number.


+----------------------------------------------------------------------+
|  Roland Schilling                      Home-Office: +49(89)32929-670 |
|  Max-Planck-Institut für Gravitationsphysik                          |
|  -- Albert-Einstein-Institut --                                      |
|  D-85748 Garching                           E-mail:   ros@rzg.mpg.de |
|  Germany                                  http://www.aei-hannover.de |
+----------------------------------------------------------------------+
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Comment 13 Jerry DeLisle 2009-10-02 13:57:12 UTC
Subject: Re:  [4.3/4.4/4.5 Regression] PARAMETER statement
 in module subroutines

On 10/02/2009 05:35 AM, ros at rzg dot mpg dot de wrote:
>
>
> ------- Comment #12 from ros at rzg dot mpg dot de  2009-10-02 12:35 -------
> Subject: Re:  [4.3/4.4/4.5 Regression] PARAMETER statement
>   in module subroutines
>
> On Fri, 2 Oct 2009, burnus at gcc dot gnu dot org wrote:
>
>> Depends where you download the binary from. For my x86-64 builds, one can find
>> it in the file name (click on "Download page." or go directly to
>> http://users.physik.fu-berlin.de/~tburnus/gcc-trunk/ )
>
> Thanks, but unfortunately I need a 32-bit version.

The build Tobias mentioned is a nightly update to latest 4.5 trunk version.

http://quatramaran.ens.fr/~coudert/gfortran/gfortran-4.5-linux-i686.tar.gz

The update starts at about 11:00 PM PST every day and is uploaded 
several hours later.

Jerry