Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!mcnc!uvaarpa!murdoch!murdoch.acc.virginia.edu!bglenden From: bglenden@mandrill.cv.nrao.edu (Brian Glendenning) Newsgroups: comp.lang.misc Subject: Re: C vs. FORTRAN aliasing Message-ID: Date: 21 Nov 90 19:21:52 GMT References: <15704.274a7509@levels.sait.edu.au> Sender: news@murdoch.acc.Virginia.EDU Organization: National Radio Astronomy Observatory Lines: 32 In-Reply-To: rang@cs.wisc.edu's message of 21 Nov 90 17:59:39 GMT In article rang@cs.wisc.edu (Anton Rang) writes: In article <15704.274a7509@levels.sait.edu.au> ccml@levels.sait.edu.au writes: >I wrote: >> SUBROUTINE BLAH(X,Y) >> INTEGER X,Y >> X = 3 >> Y = 2 >> IF (A(X) .EQ. 0) ... >> >> [edited down] >> A compiler for FORTRAN can optimize the test to be A(3) since it >> knows that the assignment to Y can never change X. A compiler for C, >> in the absence of interprocedural aliasing information, cannot do the >> same. > >Assuming that there was no 'EQUIVALENCE (a,b)' in the routine >which does the 'CALL BLAH(a,b)'! If there was, then the program is erroneous (not legal FORTRAN, I'm not sure if 'erroneous' is the term ANSI uses in the FORTRAN spec). In a legal FORTRAN program, X and Y can never be aliased (strictly speaking, program execution can not depend on whether X and Y are aliased or not). Do real compilers ever complain about this? Or do FORTRAN compilers just assume that that users will never alias subroutine arguments? Brian -- Brian Glendenning - National Radio Astronomy Observatory bglenden@nrao.edu bglenden@nrao.bitnet (804) 296-0286