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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Why is the destructor called multiple times after I declare an object? Date: Wed, 13 Jan 2016 21:18:44 +0100 Organization: JSA Research & Innovation Message-ID: <87pox544ij.fsf@adaheads.sparre-andersen.dk> References: <293c58ac-4ebd-488a-abcc-b6e88811eec8@googlegroups.com> <871t9ogevj.fsf@theworld.com> NNTP-Posting-Host: 109.56.94.95.mobile.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1452716324 8707 109.56.94.95 (13 Jan 2016 20:18:44 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 13 Jan 2016 20:18:44 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:zhhh2oUR0mtk9JMhRYjldOhyWd4= Xref: news.eternal-september.org comp.lang.ada:29119 Date: 2016-01-13T21:18:44+01:00 List-Id: Bob Duff writes: > Brian Drummond writes: > For nonlimited types, the compiler is free to use build-in-place if it > can prove that it's equivalent to return-by-copy. It's often not > equivalent. For example: > > X := Init; > > What if Init raises an exception after partly modifying the result? > In that case X should not be modified, so the result object of Init > and X had better not be at the same address. But if: a) There is no exception handler between the assignment and leaving the scope of X, build-in-place is okay (but impractical)? b) The compiler can prove that no exceptions can occur after the first modification of the result inside Init, build-in-place is okay? Greetings, Jacob -- "The butcher backed into the meat grinder and got a little behind in his work."