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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b3f788f59498d3af X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Exceptions and out procedure arguments (using GNAT GPL) Date: Fri, 15 Jun 2007 22:08:44 -0500 Organization: Jacob's private Usenet server Message-ID: References: <79c673pq5htg508nkoi935n3udqg5ps7r8@4ax.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1181963187 23491 69.95.181.76 (16 Jun 2007 03:06:27 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 16 Jun 2007 03:06:27 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news1.google.com comp.lang.ada:16205 Date: 2007-06-15T22:08:44-05:00 List-Id: "Fionn Mac Cumhaill" 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.