public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35381]  New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression
@ 2008-02-26 17:20 thomas dot orgis at awi dot de
  2008-02-26 17:38 ` [Bug fortran/35381] Misleading error message with derived types: " thomas dot orgis at awi dot de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: thomas dot orgis at awi dot de @ 2008-02-26 17:20 UTC (permalink / raw)
  To: gcc-bugs

We have a set of code that works with SUN and Intel compilers and that should
be correct to the best of our knowledge, but triggers a strange error by
gfortran 4.1.0 and 4.2.3 .
The stripped-down exapmple here has been tested with 4.1.0 on x86-64, I got the
qualitatively same error on the full source with 4.2.3 on x86, too.

Here is the output of compilation:

me@box> gfortran -v -save-temps -c -g baddata.f90
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib
--with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic
--host=x86_64-suse-linux
Thread model: posix
gcc version 4.1.0 (SUSE Linux)
 /usr/lib64/gcc/x86_64-suse-linux/4.1.0/f951 baddata.f90 -quiet -dumpbase
baddata.f90 -mtune=generic -auxbase baddata -g -version -o baddata.s
GNU F95 version 4.1.0 (SUSE Linux) (x86_64-suse-linux)
        compiled by GNU C version 4.1.0 (SUSE Linux).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 In file baddata.f90:50

    1._dp / (1._dp - rxyzkappa), &
        1
Error: Exponent at (1) must be INTEGER for an initialization expression
 In file baddata.f90:72

    rerg = rconst * rrhoTheta**dat_sig%gamma
                1
Error: Symbol 'rconst' at (1) has no IMPLICIT type


And here is the code (baddata.f90):

! This example file is stripped from a program that compiles and works fine
with Intel or SUN compilers...
! gfortran 4.2.3 showed an identical error as 4.1.0
! During reduction of code for the example, the complained position varied but
the basic parser error stayed the same with 4.1.0 .
! The essence is this:
!    1._dp / (1._dp - rxyzkappa), &
!        1
!Error: Exponent at (1) must be INTEGER for an initialization expression

MODULE precision

  IMPLICIT NONE
  PUBLIC

  INTEGER, PARAMETER :: dp = 4

END MODULE precision

MODULE data

  USE precision

  IMPLICIT NONE
  PRIVATE

  INTEGER, PARAMETER :: dat_dimension = 2
  TYPE dat_sigtype
    INTEGER :: dimension
    real(kind=4), DIMENSION(dat_dimension) :: rmin
    real(kind=4), DIMENSION(dat_dimension) :: rmax
    real(kind=4) :: gravity
    real(kind=4) :: omega
    real(kind=4) :: gasconst
    real(kind=4) :: p0
    real(kind=4) :: kappa
    real(kind=4) :: gamma
    real(kind=4) :: rcp
  END TYPE dat_sigtype

  real(kind=4), PARAMETER :: rxyzR= 287.E-6_dp
  real(kind=4), PARAMETER :: rxyzkappa= 0.284_dp
  TYPE(dat_sigtype), PARAMETER :: dat_sig = dat_sigtype( &
    dat_dimension, &
    (/ 0._dp, 0._dp /), &
    (/ 28.0E3_dp, 10.0_dp /), &
    9.81E-3_dp, &
    7.292E-5_dp, &
    rxyzR, &
    .101300_dp, &
    rxyzkappa, &
    1._dp / (1._dp - rxyzkappa), &
    rxyzR / rxyzkappa )

CONTAINS

! The code compiles fine when you remove that function.
! It has trouble with rconst...
!    rerg = rconst * rrhoTheta**dat_sig%gamma
!                1
! Error: Symbol 'rconst' at (1) has no IMPLICIT type

  FUNCTION dat_diagP(rrhoTheta) RESULT(rerg)
    IMPLICIT NONE

    real(kind=4), INTENT(in) :: rrhoTheta

    real(kind=4) :: rerg

    real(kind=4), PARAMETER :: rconst &
      = dat_sig%gasconst**dat_sig%gamma / &
      dat_sig%p0**(dat_sig%kappa*dat_sig%gamma)

    rerg = rconst * rrhoTheta**dat_sig%gamma

  END FUNCTION dat_diagP


END MODULE data


-- 
           Summary: Real initialization problem (invalid error): Exponent at
                    (1) must be INTEGER for an initialization expression
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas dot orgis at awi dot de
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
@ 2008-02-26 17:38 ` thomas dot orgis at awi dot de
  2008-02-27  2:14 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: thomas dot orgis at awi dot de @ 2008-02-26 17:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from thomas dot orgis at awi dot de  2008-02-26 17:37 -------
I stripped a bit more and I think I got the root of the problem, illustrated by
this more minimal example:

MODULE data

  IMPLICIT NONE
  PRIVATE

  INTEGER, PARAMETER :: dat_dimension = 2
  TYPE dat_sigtype
    real(kind=4) :: gamma
  END TYPE dat_sigtype

  TYPE(dat_sigtype), PARAMETER :: dat_sig = dat_sigtype( 1.3_4 )

  real(kind=4), PARAMETER :: expo = 1.3_4

  real(kind=4), PARAMETER :: rconst  = 2._4**dat_sig%gamma
  real(kind=4), PARAMETER :: rconst2 = 2._4**expo

CONTAINS

END MODULE data

...and these gcc messages:

 In file baddata.f90:11

  TYPE(dat_sigtype), PARAMETER :: dat_sig = dat_sigtype( 1.3_4 )
                                                       1
Error: Exponent at (1) must be INTEGER for an initialization expression
 In file baddata.f90:16

  real(kind=4), PARAMETER :: rconst2 = 2._4**expo
                                                1
Error: Exponent at (1) must be INTEGER for an initialization expression


So we are dealing with a limitation (in accordance to F95 standard, as I
read... and thus correct here) with initialization.
The problem I still have with gcc here is that when the exponent comes from a
derived type, the error message points to the exponents definition (which is
correct code) and not the the bad initialization code (which is not correct
code).


-- 

thomas dot orgis at awi dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Real initialization problem |Misleading error message
                   |(invalid error): Exponent at|with derived types: Exponent
                   |(1) must be INTEGER for an  |at (1) must be INTEGER for
                   |initialization expression   |an initialization expression


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
  2008-02-26 17:38 ` [Bug fortran/35381] Misleading error message with derived types: " thomas dot orgis at awi dot de
@ 2008-02-27  2:14 ` jvdelisle at gcc dot gnu dot org
  2008-02-27 10:13 ` thomas dot orgis at awi dot de
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-02-27  2:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2008-02-27 02:14 -------
The problem exists in gfortran 4.2 but is fixed in 4.3 Suggest you update to
4.3.

You can get binaries at http://gcc.gnu.org/wiki/GFortranBinaries if your distro
does not provide 4.3 yet.


-- 


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
  2008-02-26 17:38 ` [Bug fortran/35381] Misleading error message with derived types: " thomas dot orgis at awi dot de
  2008-02-27  2:14 ` jvdelisle at gcc dot gnu dot org
@ 2008-02-27 10:13 ` thomas dot orgis at awi dot de
  2008-02-28  5:00 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: thomas dot orgis at awi dot de @ 2008-02-27 10:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from thomas dot orgis at awi dot de  2008-02-27 10:12 -------
Well, that's good to hear that this is already fixed.
Though it may be nit-picky to note that there isn't a 4.3 gfortran binary
package on the page you pointed out but only 4.2 and trunk (4.4) ;-)
I'll see when the sytem I am using here will be upgraded to 4.3 ... may take
some time (well, a release of 4.3 would also help;-).
For now I am glad that I found the real problem, have to continue with my work.

Thanks.


-- 


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
                   ` (2 preceding siblings ...)
  2008-02-27 10:13 ` thomas dot orgis at awi dot de
@ 2008-02-28  5:00 ` jvdelisle at gcc dot gnu dot org
  2008-02-28 10:11 ` fxcoudert at gcc dot gnu dot org
  2008-02-28 10:41 ` thomas dot orgis at awi dot de
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-02-28  5:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2008-02-28 04:59 -------
Yes, of course we just bumped to 4.4 a few days ago.


-- 


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
                   ` (3 preceding siblings ...)
  2008-02-28  5:00 ` jvdelisle at gcc dot gnu dot org
@ 2008-02-28 10:11 ` fxcoudert at gcc dot gnu dot org
  2008-02-28 10:41 ` thomas dot orgis at awi dot de
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-02-28 10:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2008-02-28 10:10 -------
Marking the bug as FIXED in 4.3.0 and later. Thanks for the bug report!


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
  GCC build triplet|x86_64-suse-linux           |
   GCC host triplet|x86_64-suse-linux           |
 GCC target triplet|x86_64-suse-linux           |
           Keywords|                            |rejects-valid
      Known to fail|                            |4.1.0 4.2.3
      Known to work|                            |4.3.0 4.4.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

* [Bug fortran/35381] Misleading error message with derived types: Exponent at (1) must be INTEGER for an initialization expression
  2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
                   ` (4 preceding siblings ...)
  2008-02-28 10:11 ` fxcoudert at gcc dot gnu dot org
@ 2008-02-28 10:41 ` thomas dot orgis at awi dot de
  5 siblings, 0 replies; 7+ messages in thread
From: thomas dot orgis at awi dot de @ 2008-02-28 10:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from thomas dot orgis at awi dot de  2008-02-28 10:40 -------
Eh... one question: Does the fix in 4.3 "just" make the initialization with
REAL exponent work (Fortran 2003, AFAIK) or does it also fix the error message
when working in strict Fortran 95 mode (hm, I suppose there is a strict mode),
where the code still should be rejected?


-- 


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


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

end of thread, other threads:[~2008-02-28 10:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 17:20 [Bug fortran/35381] New: Real initialization problem (invalid error): Exponent at (1) must be INTEGER for an initialization expression thomas dot orgis at awi dot de
2008-02-26 17:38 ` [Bug fortran/35381] Misleading error message with derived types: " thomas dot orgis at awi dot de
2008-02-27  2:14 ` jvdelisle at gcc dot gnu dot org
2008-02-27 10:13 ` thomas dot orgis at awi dot de
2008-02-28  5:00 ` jvdelisle at gcc dot gnu dot org
2008-02-28 10:11 ` fxcoudert at gcc dot gnu dot org
2008-02-28 10:41 ` thomas dot orgis at awi dot de

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