Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!lotus!esegue!johnl From: johnl@esegue.uucp (John Levine) Newsgroups: comp.lang.fortran Subject: Re: FORTRAN array aliasing -- potential problems? Message-ID: <1989Jul31.234746.2655@esegue.uucp> Date: 31 Jul 89 23:47:46 GMT References: <8907311910.AA15243@robalo.nyu.edu> Reply-To: johnl@esegue.UUCP (John Levine) Organization: Segue Software, Cambridge MA Lines: 24 In article <8907311910.AA15243@robalo.nyu.edu> mckenney@ROBALO.NYU.EDU (Alan McKenney) writes: > I am considering a situation in which I would call a FORTRAN >subroutine which has several dummy argument arrays using the >same actual array. Example: > > SUBROUTINE SUB1( N, A, LDA, B, LDB, C, LDC, .... ) > > .... coding which sets and then uses A, then sets and uses B > without referencing A again, then sets and uses C without > referencing A or B again. ... It's easy to imagine a situation where using the same array for A, B, and C would get you into trouble, even though they are used in disjoint parts of the program. A modern compiler that uses graph coloring for register assignment tends to get everything into registers that it can. On a machine with lots of registers, at the end of the routine it might well have values of A(I) and B(J) lying around that it hadn't yet stored, and would then store them away, clobbering C(I) and C(J) that you expect. Fortran compiler writers know and depend on the no aliasing rule and you'll certainly be bitten sooner or later. -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 492 3869 {ima|lotus}!esegue!johnl, johnl@ima.isc.com, Levine@YALE.something Massachusetts has 64 licensed drivers who are over 100 years old. -The Globe