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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,23ade4b42d9cb5f0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-21 10:54:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Eliminating copying in Gnat Date: Tue, 21 Jan 2003 12:54:53 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:33306 Date: 2003-01-21T12:54:53-06:00 List-Id: Grein, Christoph wrote in message ... >> Victor Porton wrote: >> : But Adjust is called 3 times :-( >> >> Are compilers allowed to optimize away an Adjust? >> Might Adjust not have side effects? > >Read RM 7.6. There is a detailed description of the model how functions deal >with their intermediate objects. Optimizations are allowed so that the number of >calls of Adjust may vary. > >Gnat has three calls, Rational Apex two in this case. Word of warning: that description in 7.6 is pretty bad; it contains several errors that both allow too much optimization and too little. This is fixed by AI-147 (WG9 approved in December). The basic summary: There is no optimization of calls for limited types. For non-limited types, removal of temporaries and their associated pairs of Adjust-Finalization operations is allowed. Dead variables with trivial Initialize also can be removed. In any case, this is an OPTIMIZATION. There is no requirement that a compiler do any optimization here. (Given how dangerous and confused the RM rules are, I'm not surprised if an implementor doesn't do any.) This area was a major problem for Claw, as at least one implementation did implement the RM rules as written, which makes it impossible to adjust pointers to objects during an assignment. That implementation has thankfully been fixed. Randy.