This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug fc107


Tobias Schlüter wrote:

Walt Brainerd wrote:


PROGRAM fc107

! Submitted by Walt Brainerd, The Fortran Company
! GNU Fortran 95 (GCC 4.1.0 20050322 (experimental))
! Windows XP

! Output should be 3

! Output is 999

     INTEGER I
     INTEGER TRYME
     I = 3
     print *, tryme((i),i)
     END

INTEGER FUNCTION TRYME(RTNME,HITME)
INTEGER RTNME,HITME
HITME = 999
TRYME = RTNME
END



This is an interesting corner case. This means that we have to keep track of parentheses (at least the outermost ones in an expression) for correctness. NB, very much along the same lines SIZE((X)) with X an array is not a constant, restricted or initialization expression for the same reason.

I linked to this thread from PR 14771 and updated it's severity accordingly.

- Tobi


There are several places where you need to know whether
something can be defined (ie, left of an assignment stmt)
or is a more general expression. Passing (X) instead of X
has forever been a way to pass something "sorta by value",
rather than by reference.

SIZE((X)) is a perfectly legal initialization expression,
provided X is an array parameter, for example. The
parens don't make any difference here. (An initialization
expression in parens is also an initialization expression--
same for the others.)

--
Walt Brainerd         +1-877-355-6640 (voice & fax)
The Fortran Company   +1-520-760-1397 (outside USA)
6025 N. Wilmot Road   walt@fortran.com
Tucson, AZ 85750 USA  http://www.fortran.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]