From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Passing the same actual as both in and out formal parameters?
Date: Tue, 17 Nov 2009 01:50:04 -0800 (PST)
Date: 2009-11-17T01:50:04-08:00 [thread overview]
Message-ID: <1fbe454c-52b0-408b-9159-982fc019a53c@j19g2000yqk.googlegroups.com> (raw)
Consider:
type T is tagged private;
procedure P (A : in T; B : out T) is separate;
Object : T;
begin
P (A => Object, B => Object);
This seems legal but I suspect the execution might lead to bugs if P
reads and writes components of A and B in arbitrary order, e.g.
type T is tagged record
L, M : Integer;
end record;
procedure P (A : in T; B : out T) is
begin
B.L := A.M; -- does this change A.L too?
B.M := A.L; -- bug: A.L has been clobbered, now B.M = B.L?
end P;
My concern stems from the fact that T is tagged (I cannot change
that), so Object is passed by reference as both A and B.
Am I right to be concerned?
--
Ludovic Brenta.
next reply other threads:[~2009-11-17 9:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 9:50 Ludovic Brenta [this message]
2009-11-17 10:31 ` Passing the same actual as both in and out formal parameters? Jean-Pierre Rosen
2009-11-17 11:26 ` Ludovic Brenta
2009-11-17 13:13 ` Jean-Pierre Rosen
2009-11-17 16:07 ` Ludovic Brenta
2009-11-18 10:00 ` Jean-Pierre Rosen
2009-11-17 10:40 ` Niklas Holsti
2009-11-17 16:26 ` Adam Beneschan
2009-11-17 21:25 ` Randy Brukardt
2009-11-18 0:11 ` Jeffrey R. Carter
2009-11-18 0:23 ` Adam Beneschan
2009-11-18 3:47 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox