Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!ncar!bierstat.scd.ucar.edu!fred From: fred@balzac.scd.ucar.edu (Fred Clare) Newsgroups: comp.lang.fortran Subject: Re: Duplicate names in formal parameter lists Message-ID: <8927@ncar.ucar.edu> Date: 23 Oct 90 23:09:24 GMT References: <11084@hubcap.clemson.edu> Sender: news@ncar.ucar.edu Reply-To: fred@balzac.scd.ucar.edu (Fred Clare) Distribution: usa Organization: Scientific Computing Division / NCAR, Boulder Co. Lines: 46 In article <11084@hubcap.clemson.edu>, mjs@hubcap.clemson.edu (m j saltzman) writes: > I discovered an error in a FORTRAN program I was modifying, which amounts > to the following: > > SUBROUTINE FOO(X, [other parameters], X) > DOUBLE PRECISION X(N) > > [rest of code] > > This compiled without error on a Sun (with the -u flag) and on ULTRICS. > Fortunately (?), the calling routine supplied the same argument in both > positions, so no error occurred during execution. > > Questions: Is this really legal FORTRAN 77? If so, is it useful for > anything? What are the semantics of a call to the routine with different > arguments, say FOO(Y, ..., Z)? If not, why don't common compilers > (at least these) detect the error? Other types of duplicate declarations > are detected. > > Thanks for any insight. > > Matthew Saltzman > mjs@clemson.edu Section 15.9.3.6 of the Fortran standard states: If a subprogram reference causes a dummy argument in the referenced subprogram to become associated with another dummy argument in the referenced subprogram, neither dummy argument may become defined during execution of that subprogram. For example, if a subroutine is headed by SUBROUTINE XYZ (A,B) and is referenced by CALL XYZ (C,C) then the dummy arguments A and B each become associated with the same actual argument C and therefore with each other. Neither A nor B may become defined during this execution of subroutine XYZ or by procedures referenced by XYZ Fred Clare NCAR (National Center for Atmospheric Research) fred@ncar.ucar.edu