comp.lang.ada
 help / color / mirror / Atom feed
* Passing the same actual as both in and out formal parameters?
@ 2009-11-17  9:50 Ludovic Brenta
  2009-11-17 10:31 ` Jean-Pierre Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Ludovic Brenta @ 2009-11-17  9:50 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-11-18 10:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17  9:50 Passing the same actual as both in and out formal parameters? Ludovic Brenta
2009-11-17 10:31 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox