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
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.
(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];
*** Bug 41520 has been marked as a duplicate of this bug. ***
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
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
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
FIXED for GCC 4.5 (trunk), 4.4 and 4.3. Thanks for the bugreport!
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
(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
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
(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).
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
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