Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!caen!math.lsa.umich.edu!sharkey!msuinfo!rang From: rang@cs.wisc.edu (Anton Rang) Newsgroups: comp.lang.misc Subject: Re: C vs. FORTRAN aliasing Message-ID: Date: 21 Nov 90 17:59:39 GMT References: <15704.274a7509@levels.sait.edu.au> Sender: news@msuinfo.cl.msu.edu Organization: UW-Madison CS department Lines: 24 In-Reply-To: ccml@levels.sait.edu.au's message of 21 Nov 90 12:37:29 GMT 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). Anton +---------------------------+------------------+-------------+ | Anton Rang (grad student) | rang@cs.wisc.edu | UW--Madison | +---------------------------+------------------+-------------+