From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!elma.epfl.ch!madmats From: madmats@elma.epfl.ch (Mats Weber) Newsgroups: comp.lang.ada Subject: Parameter passing mechanisms Message-ID: <890220173849.21a00314@elcc.epfl.ch> Date: 20 Feb 89 16:38:49 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Question: is the following program erroneous ? procedure Is_This_Program_Erroneous is type Vector is array (1..5) of Float; A_Vector : Vector := (0.35, 0.67, 1.8, 2.0, 7.7); procedure Add (V : in Vector; W : in out Vector) is begin for I in 1..5 loop W(I) := V(I) + W(I); end loop; end Add; begin Add(A_Vector, A_Vector); end Is_This_Program_Erroneous; The effect of this program does not depend on the parameter passing mechanism (copy or reference). Note that a similar example is said to be correct in "Rationale for the design of the Ada language". According to LRM 6.2(7), the program is correct because its effect does not depend on the parameter passing mechanism. But according to LRM 6.2(13) - which is a note and as such is not part of the standard - the program is erroneous because there are multiple access paths to A_Vector during the call Add(A_Vector, A_Vector);, and therefore V is undefined after the assignment W(1) := V(1) + W(1); Mats Weber Swiss Federal Institute of Technology EPFL DI LITh 1015 Lausanne Switzerland e-mail : madmats@elma.epfl.ch