public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug
@ 2005-08-05 20:32 christopherbuell at mindspring dot com
  2005-08-05 20:35 ` [Bug fortran/23254] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: christopherbuell at mindspring dot com @ 2005-08-05 20:32 UTC (permalink / raw)
  To: gcc-bugs

While testing some FORTRAN 90 code under Fedora Core 4,
I found problem initializing COMPLEX PARAMETERs with other
parameters that have + or - in front of the variable name.

The following .f90 test code will illustrate the problem.
All lines should compile fine.
The lines that fail are commented with "fail"

module consts_test

  real(8), parameter :: konst1 = 1.0d0

  complex, parameter :: const1 = (1.0d0,1.0d0)        ! good
  complex, parameter :: const2 = (1.0d0,-1.0d0)       ! good
  complex, parameter :: const3 = (-1.0d0,-1.0d0)      ! good
  complex, parameter :: const4 = (-1.0d0,1.0d0)       ! good
  complex, parameter :: const5 = (+1.0d0,+1.0d0)      ! good
  complex, parameter :: const6 = (konst1,konst1)      ! good
  complex, parameter :: const7 = (konst1,-konst1)     ! fail
  complex, parameter :: const8 = (-konst1,-konst1)    ! fail
  complex, parameter :: const9 = (-konst1,konst1)     ! fail
  complex, parameter :: const10 = (+konst1,+konst1)   ! fail

end module consts_test

!! GNU Fortran 95 (GCC 4.0.0 20050519 (Red Hat 4.0.0-8))
!! Copyright (C) 2005 Free Software Foundation, Inc.

!! GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
!! You may redistribute copies of GNU Fortran
!! under the terms of the GNU General Public License.
!! For more information about these matters, see the file named COPYING

-- 
           Summary: gfortran .f90 complex parameter initialization syntax
                    bug
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christopherbuell at mindspring dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug fortran/23254] gfortran .f90 complex parameter initialization syntax bug
  2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
@ 2005-08-05 20:35 ` pinskia at gcc dot gnu dot org
  2005-08-05 22:52 ` kargl at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05 20:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-05 20:35 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
      Known to fail|                            |4.0.0 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-05 20:35:11
               date|                            |


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


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

* [Bug fortran/23254] gfortran .f90 complex parameter initialization syntax bug
  2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
  2005-08-05 20:35 ` [Bug fortran/23254] " pinskia at gcc dot gnu dot org
@ 2005-08-05 22:52 ` kargl at gcc dot gnu dot org
  2005-08-06  2:38 ` kargl at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2005-08-05 22:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kargl at gcc dot gnu dot org  2005-08-05 22:52 -------
The code appears to be illegal.  Lahey reports

Compiling program unit consts_test at line 1:
  1034-S: "SOURCE.F90", line 10: Right parenthesis missing or position of right
parenthesis invalid.
  1034-S: "SOURCE.F90", line 11: Right parenthesis missing or position of right
parenthesis invalid.
  1034-S: "SOURCE.F90", line 12: Right parenthesis missing or position of right
parenthesis invalid.
  1034-S: "SOURCE.F90", line 13: Right parenthesis missing or position of right
parenthesis invalid.
  1034-S: "SOURCE.F90", line 14: Right parenthesis missing or position of right
parenthesis invalid.
Encountered 5 errors, 0 warnings, 0 informations in file SOURCE.F90.
Compiling file SOURCE.F90.



-- 


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


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

* [Bug fortran/23254] gfortran .f90 complex parameter initialization syntax bug
  2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
  2005-08-05 20:35 ` [Bug fortran/23254] " pinskia at gcc dot gnu dot org
  2005-08-05 22:52 ` kargl at gcc dot gnu dot org
@ 2005-08-06  2:38 ` kargl at gcc dot gnu dot org
  2005-08-06 15:02 ` christopherbuell at mindspring dot com
  2005-08-06 16:03 ` sgk at troutmask dot apl dot washington dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2005-08-06  2:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kargl at gcc dot gnu dot org  2005-08-06 02:38 -------
gfortran is doing the right thing according to section 7.1.6.1
of the Fortran 95 standard.  For completeness, here is the output
of NAGWare F95 compiler.

kargl[204] f95 -kind=byte -c lk.f90
Error: lk.f90, line 10: Invalid real part of complex constant
Error: lk.f90, line 11: Invalid real part of complex constant
Error: lk.f90, line 12: Invalid real part of complex constant
Error: lk.f90, line 13: Invalid real part of complex constant
Error: lk.f90, line 14: Invalid real part of complex constant
Errors in declarations, no further processing for CONSTS_TEST


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug fortran/23254] gfortran .f90 complex parameter initialization syntax bug
  2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
                   ` (2 preceding siblings ...)
  2005-08-06  2:38 ` kargl at gcc dot gnu dot org
@ 2005-08-06 15:02 ` christopherbuell at mindspring dot com
  2005-08-06 16:03 ` sgk at troutmask dot apl dot washington dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: christopherbuell at mindspring dot com @ 2005-08-06 15:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From christopherbuell at mindspring dot com  2005-08-06 15:02 -------
(In reply to comment #3)

Got it. I don't know the F90 or F95 standard very well.
I do know F77.
The code I was porting did compile on the MS-DEC FORTRAN 95 compiler.
(whoever owns that compiler anyway)
It seems "reasonable" that it should work.
But, I didn't know what the spec said.

Thanx for getting back to me.

Chris
> gfortran is doing the right thing according to section 7.1.6.1
> of the Fortran 95 standard.  For completeness, here is the output
> of NAGWare F95 compiler.
> kargl[204] f95 -kind=byte -c lk.f90
> Error: lk.f90, line 10: Invalid real part of complex constant
> Error: lk.f90, line 11: Invalid real part of complex constant
> Error: lk.f90, line 12: Invalid real part of complex constant
> Error: lk.f90, line 13: Invalid real part of complex constant
> Error: lk.f90, line 14: Invalid real part of complex constant
> Errors in declarations, no further processing for CONSTS_TEST



-- 


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


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

* [Bug fortran/23254] gfortran .f90 complex parameter initialization syntax bug
  2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
                   ` (3 preceding siblings ...)
  2005-08-06 15:02 ` christopherbuell at mindspring dot com
@ 2005-08-06 16:03 ` sgk at troutmask dot apl dot washington dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-08-06 16:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-08-06 16:03 -------
Subject: Re:  gfortran .f90 complex parameter initialization syntax bug

On Sat, Aug 06, 2005 at 03:02:37PM -0000, christopherbuell at mindspring dot com wrote:
> 
> (In reply to comment #3)
> 
> Got it. I don't know the F90 or F95 standard very well.

The Standard can be tricky to read.  I have a draft of
F2003 here so I'll quote that

7.1.7     Initialization expression
An initialization expression is an expression with limitations that
make it suitable for use as a kind type parameter, initializer, or
named constant.  It is an expression in which each operation is
intrinsic, and each primary is
      (1)      A constant or subobject of a constant,
      (2)-(11) Don't apply.

real, parameter    :: x = -1.e0         ! Uses a constant.
complex, parameter :: z = (1.e0, -1.e0) ! Uses constants.
complex, parameter :: c = (x,-x)        ! x is a named constant, -x is not.

You probably found a vendor extension, because -x could be
evaluated at compile time.

If you really want to sit and puzzle over the standard.  Consider

program c
   real, parameter :: o = 1.e0
   real, parameter :: t = 2.e0
   real, parameter :: h = o / t           ! This is ok.
   complex, parameter :: z = (o / t, h)   ! This is not ok.
   print *, o, t, h
end program c




-- 


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


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

end of thread, other threads:[~2005-08-06 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-05 20:32 [Bug fortran/23254] New: gfortran .f90 complex parameter initialization syntax bug christopherbuell at mindspring dot com
2005-08-05 20:35 ` [Bug fortran/23254] " pinskia at gcc dot gnu dot org
2005-08-05 22:52 ` kargl at gcc dot gnu dot org
2005-08-06  2:38 ` kargl at gcc dot gnu dot org
2005-08-06 15:02 ` christopherbuell at mindspring dot com
2005-08-06 16:03 ` sgk at troutmask dot apl dot washington dot edu

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