Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!hc!beta!unm-la!unmvax!nmtsun!hydrovax From: hydrovax@nmtsun.nmt.edu (M. Warner Losh) Newsgroups: comp.lang.c Subject: Re: mini-flame re: Fortran arguments and `noalias' Summary: ON VMS it isn't even used. Keywords: pragmas, compiler hints Message-ID: <1226@nmtsun.nmt.edu> Date: 13 Jan 88 20:44:47 GMT References: <485@cresswell.quintus.UUCP> <1453@cuuxb.ATT.COM> <9934@mimsy.UUCP> <10144@mimsy.UUCP> Organization: NMT Hydrology program Lines: 44 In article <10144@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > >In article <9934@mimsy.UUCP> I mentioned > >>Some FORTRAN compilers may indeed use copy-in/copy-out ... > >>but I think it is not mandated. > > ^^^^^ > Seriously, though, since value-result is *not* mandated, those > writing Fortran code should not count on it. On VMS btw, FORTRAN uses call by reference for ALL of it's arguements. This presents many aliasing problems. Consider the following code: PROGRAM FOO COMMON X X = 4 CALL BAR (X) END SUBROUTINE BAR (Y) COMMON X Y = X * Y WRITE (*,*) X RETURN END now then, X and Y are aliases for each other. Yes, Quite a problem. In fact, I seem to remeber seeing something like this breaking the Optimizer in an ancient version of VMS FORTRAN. The point is, that if your compiler uses call by reference (which I maintain that most do), then you will get 16 printed. If it uses call by value-return (copy-in,copy-out), then you should get 4. The point is that not only should you not write code that depends on one, or the other of these features, because it is non-portable. You should avoid it because it produces LOTS AND LOTS of hard to find bugs. -- bitnet: lush@nmt.csnet M. Warner Losh csnet: warner%hydrovax@nmtsun uucp: ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!hydrovax Warning: Hydrovax is both a machine, and an account, so be careful.