Article View: comp.lang.misc
Article #2208Re: C vs. FORTRAN aliasing
From: Brian Glendenning
Date: Wed, 21 Nov 1990 19:21
Date: Wed, 21 Nov 1990 19:21
32 lines
1914 bytes
1914 bytes
In article <RANG.90Nov21115939@nexus.cs.wisc.edu> 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
Technical Details
Message-ID:
<BGLENDEN.90Nov21142152@mandrill.cv.nrao.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!mcnc!uvaarpa!murdoch!murdoch.acc.virginia.edu!bglendenReferences:
<RANG.90Nov18160113@nexus.cs.wisc.edu> <15704.274a7509@levels.sait.edu.au> <RANG.90Nov21115939@nexus.cs.wisc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <BGLENDEN.90Nov21142152@mandrill.cv.nrao.edu> Date: 21 Nov 90 19:21:52 GMT References: <RANG.90Nov18160113@nexus.cs.wisc.edu> <15704.274a7509@levels.sait.edu.au> <RANG.90Nov21115939@nexus.cs.wisc.edu> 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