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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Why is the destructor called multiple times after I declare an object? Date: Mon, 11 Jan 2016 17:43:36 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <293c58ac-4ebd-488a-abcc-b6e88811eec8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 12 Jan 2016 00:40:56 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="19995"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18teSdx5TRnoIGb0WXTeubHR9CoOKh6B54=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 In-Reply-To: X-Mozilla-News-Host: news://freenews.netfront.net Cancel-Lock: sha1:YG/RNdFdNPF/AfBuvUtsSqCLL9s= Xref: news.eternal-september.org comp.lang.ada:29095 Date: 2016-01-11T17:43:36-07:00 List-Id: On 01/11/2016 09:29 AM, Brian Drummond wrote: > > Somehow I expected "extended return" to allocate space and "build in > place" during the execution of the return statement. Extended return is required for a limited type other than returning a function call or aggregate. Limited types are build in place. But using an extended return for a non-build-in-place type makes no difference. > Is this something legal that Gnat doesn't take advantage of? Or is there > a Gnat option I'm not aware of? A compiler can eliminate the anonymous object if it can be sure the result is always the same as using it. It can build in place when not so required if it can be sure the result is always the same as not building in place. -- Jeff Carter "C's solution to this [variable-sized array parameters] has real problems, and people who are complaining about safety definitely have a point." Dennis Ritchie 25