comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Exceptions and out procedure arguments (using GNAT GPL)
Date: Fri, 15 Jun 2007 22:08:44 -0500
Date: 2007-06-15T22:08:44-05:00	[thread overview]
Message-ID: <f4vk3j$mu3$1@jacob-sparre.dk> (raw)
In-Reply-To: 79c673pq5htg508nkoi935n3udqg5ps7r8@4ax.com

"Fionn Mac Cumhaill" <invisible@hiding.from.spam> wrote in message
news:79c673pq5htg508nkoi935n3udqg5ps7r8@4ax.com...
...
> Will X get a value of 999? I.e., is an Ada compiler free to optimize
> the code such that the assignment to the out variable O is moved to
> some place after the point where the exception is raised?

My gut feeling (not one backed up by checking the rules in detail) is that
it depends on how the parameters are passed. Integers are a by-copy type, so
a compiler that modified X would be wrong: the copy back into X occurs on
the return from the call, and when the exception is raised that copy back
will not be executed.

Conversely, if the parameter is a by-reference type, then the assignment
should be reflected. (But I'd have to read the 11.6 rules ten times to be
sure, and it probably would depend on the actual code in the subprogram.)
Surely, Janus/Ada would make the assignment in that case.

If the language does not specify the parameter passing mechanism (as for
untagged records and arrays), then either thing could happen and you should
depend on nothing.

Surely the safest rule is to never depend on the parameter being changed,
but either thing can happen.

                           Randy.





  parent reply	other threads:[~2007-06-16  3:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-16  1:05 Exceptions and out procedure arguments (using GNAT GPL) Fionn Mac Cumhaill
2007-06-16  1:53 ` Anh Vo
2007-06-16  2:50 ` Brian May
2007-06-16  3:08 ` Randy Brukardt [this message]
2007-06-16  6:55 ` Dmitry A. Kazakov
2007-06-18 15:44 ` Adam Beneschan
2007-06-19  5:23   ` Fionn Mac Cumhaill
2007-06-19  7:34     ` Maciej Sobczak
2007-06-19 15:21       ` Adam Beneschan
2007-06-19 20:07         ` Dmitry A. Kazakov
2007-06-19 21:20           ` Adam Beneschan
2007-06-20  6:16             ` Georg Bauhaus
2007-06-20  8:01             ` Dmitry A. Kazakov
2007-06-20  8:45               ` Georg Bauhaus
2007-06-20  9:29                 ` Dmitry A. Kazakov
2007-06-20  6:21           ` Georg Bauhaus
2007-06-20  8:02             ` Dmitry A. Kazakov
2007-06-20  8:46               ` Georg Bauhaus
2007-06-20  9:29                 ` Dmitry A. Kazakov
2007-06-20 10:13                   ` Georg Bauhaus
2007-06-20 12:58                     ` Dmitry A. Kazakov
2007-06-20 14:16                       ` Georg Bauhaus
2007-06-20 18:22                         ` Dmitry A. Kazakov
2007-06-20 19:16                           ` Georg Bauhaus
2007-06-20 20:40                             ` Dmitry A. Kazakov
2007-06-21  9:52                               ` Georg Bauhaus
2007-06-21 13:48                                 ` Dmitry A. Kazakov
2007-06-22 18:15                                   ` Georg Bauhaus
2007-06-22 19:45                                     ` Dmitry A. Kazakov
2007-06-20 15:15         ` Fionn Mac Cumhaill
2007-06-19 21:40     ` Randy Brukardt
replies disabled

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