comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Passing the same actual as both in and out formal parameters?
Date: Tue, 17 Nov 2009 08:07:39 -0800 (PST)
Date: 2009-11-17T08:07:39-08:00	[thread overview]
Message-ID: <a1e7b064-3afe-4a46-a0e4-0c89a4542076@j24g2000yqa.googlegroups.com> (raw)
In-Reply-To: nh7udh.3ue.ln@hunter.axlog.fr

Jean-Pierre Rosen wrote:
> Ludovic Brenta a écrit :
>> My exampled was heavily simplified; the actual type has about a
>> hundred components and the procedure P is a little more complex than
>> swapping components :)
>
> > But thanks for the responses, Niklas and Jean-Pierre. They confirm my
> > suspicion.
>
> But the important thing is that there is no risk: behaviour is well
> defined, and will not change with the next release of the compiler.
>
> If it is not the behaviour you want, you can make a local copy (but you
> know that).

Indeed; I was careful not to use the phrases "bounded error" or
"erroneous execution", just "bug" :) The construct is well-defined but
error-prone and needs documentation in my sources, so I've added that.
Triggering the bug requires:

(1) pass-by-reference type (i.e. tagged, limited, etc.) or explicit
access type
(2) same object passed twice as both in and out parameters
(3) non-atomic reads and writes to the object inside the subprogram

When writing such a procedure, it is necessary to pay attention:
either prevent the bug by checking for condition (2) and raising an
exception if it is met; use only atomic operations so as to prevent
(3); or accept that the bug may happen and warn about it.

In my particular case, the operations are "atomic" in that the
procedure first reads the Object, then passes it as an "out" parameter
to another procedure, and never reads it again. However, this being
long-term-support software, one never knows that (3) can never happen
in some future revision.

--
Ludovic Brenta.



  reply	other threads:[~2009-11-17 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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