chris@mimsy.UUCP (Chris Torek) (01/12/88)
>In article <9934@mimsy.UUCP> I mentioned >>Some FORTRAN compilers may indeed use copy-in/copy-out ... >>but I think it is not mandated. > ^^^^^ In article <872@micomvax.UUCP> ray@micomvax.UUCP (Ray Dunn) writes: >You reply to a VERY descriptive, VERY well written posting which clears up >MUCH of the confusion on the meaning/impact of the aliasing question, by a >nit-picking criticism of a point irrelevant to the central theme the poster >was expounding, and OF WHICH YOU ARE NOT EVEN SURE OF THE CORRECTNESS!! Ai! Forgive me, but I lack a Fortran 77 reference manual. I would have pointed to the code, but 4BSD has been known to be buggy before. Besides, I was right :-) . Seriously, though, since value-result is *not* mandated, those writing Fortran code should not count on it. That I did not respond to the rest of Marc Mengel's article meant that I would not (at least then) argue with it (except for the claim that C has argument aliasing problems that Fortran does not). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
hydrovax@nmtsun.nmt.edu (M. Warner Losh) (01/14/88)
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.