peter@ficc.UUCP (Peter da Silva) (07/07/88)
In article <825@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: > > I saw two methods: a 170 appends a zero word terminator to the argument > > list. A 205 passes the argument list length in the length field of > > argument list > > point. > The use of a zero terminator works because FORTRAN uses call by address, > and zero is not a legal address in FORTRAN. On some machines, zero cannot > be a legal address for anything, so it would work for all calls by address > in all languages. Fortran four-plus on the PDP-11 uses the illegal address -1 for missing arguments. This isn't exactly the same as a variable length argument list, but if you specify the list length as being large enough it can serve the same purpose. I used this to implement printf() in F4P, to ease the porting of 'C' programs to Ratfor (structures weren't a problem, since the programs involved had originally been written in a CP/M 'C' subset that didn't support them). DEC uses this to allow calls that look something like: CALL QIOW(FUN,UNIT,,,,PARMS) -- -- `-_-' Peter (have you hugged your wolf today) da Silva. -- U Ferranti International Controls Corporation. -- Phone: 713-274-5180. CI$: 70216,1076. ICBM: 29 37 N / 95 36 W. -- UUCP: {uunet,academ!uhnix1,bellcore!tness1}!sugar!ficc!peter.
boyne@hplvly.HP.COM (Art Boyne) (07/12/88)
> rrr@naucse.UUCP (Bob Rose ) writes: > In article <5234@ihlpf.ATT.COM>, nevin1@ihlpf.ATT.COM (00704a-Liber) writes: > > Security in FORTRAN (with respect to calling conventions)?? Look at the > > > > subroutine foo(j) > > j = 5 > > end > > ... > > call foo(1) > > > > Oh boy! You must be using some sort of new compiler. The old one's (not > all of course) would after running this code change _all_ integer constants > of value 1 to value 5. Try debugging the code after that occurs. Bob is right - I remember spending over a week tracking down just this sort of behavior when taking a compiler class back in college. It caused an infinite loop in a memory clearing routine, wiping out all relevant variable values! Art Boyne, ...!hplabs!hplvly!boyne
jws@hpcljws.HP.COM (John Stafford) (07/15/88)
Another quirk of "changing constants" in FORTRAN is that it may change only some uses of the constant. Others may be in immediate instructions or in another literal pool and be untouched.